linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/7] dma: skip calling no-op sync ops when possible
@ 2024-01-26 13:54 Alexander Lobakin
  2024-01-26 13:54 ` [PATCH net-next 1/7] dma: compile-out DMA sync op calls when not used Alexander Lobakin
                   ` (6 more replies)
  0 siblings, 7 replies; 24+ messages in thread
From: Alexander Lobakin @ 2024-01-26 13:54 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Alexander Lobakin, Christoph Hellwig, Marek Szyprowski,
	Robin Murphy, Joerg Roedel, Will Deacon, Greg Kroah-Hartman,
	Rafael J. Wysocki, Magnus Karlsson, Maciej Fijalkowski,
	Alexander Duyck, bpf, netdev, iommu, linux-kernel

The series grew from Eric's idea and patch at [0]. The idea of using the
shortcut for direct DMA as well belongs to Chris.

When an architecture doesn't need DMA synchronization and the buffer is
not an SWIOTLB buffer, most of times the kernel and the drivers end up
calling DMA sync operations for nothing.
Even when DMA is direct, this involves a good non-inline call ladder and
eats a bunch of CPU time. With IOMMU, this results in calling indirect
calls on hotpath just to check what is already known and return.
XSk is been using a custom shortcut for that for quite some time.
I recently wanted to introduce a similar one for Page Pool. Let's combine
all this into one generic shortcut, which would cover all DMA sync ops
and all types of DMA (direct, IOMMU, ...).

* #1 adds stub inlines to be able to skip DMA sync ops or even compile
     them out when not needed.
* #2 adds the generic shortcut and enables it for direct DMA.
* #3 adds ability to skip DMA syncs behind an IOMMU.
* #4-5 are just cleanups for Page Pool to avoid merge conflicts in future.
* #6 checks for the shortcut as early as possible in the Page Pool code to
     make sure no cycles wasted.
* #7 replaces XSk's shortcut with the generic one.

On 100G NIC, the result is +3-5% for direct DMA and +10-11% for IOMMU.
As a bonus, XSk core now allows batched buffer allocations for IOMMU
setups.
If the shortcut is not available on some system, there should be no
visible performance regressions.

[0] https://lore.kernel.org/netdev/20221115182841.2640176-1-edumazet@google.com

Alexander Lobakin (5):
  dma: compile-out DMA sync op calls when not used
  page_pool: make sure frag API fields don't span between cachelines
  page_pool: don't use driver-set flags field directly
  page_pool: check for DMA sync shortcut earlier
  xsk: use generic DMA sync shortcut instead of a custom one

Eric Dumazet (2):
  dma: avoid expensive redundant calls for sync operations
  iommu/dma: avoid expensive indirect calls for sync operations

 kernel/dma/Kconfig                            |   4 +
 include/net/page_pool/types.h                 |  21 +++-
 include/linux/device.h                        |   5 +
 include/linux/dma-map-ops.h                   |  17 +++
 include/linux/dma-mapping.h                   | 100 +++++++++++++-----
 include/net/xdp_sock_drv.h                    |   7 +-
 include/net/xsk_buff_pool.h                   |  13 +--
 drivers/base/dd.c                             |   2 +
 drivers/iommu/dma-iommu.c                     |   1 +
 drivers/net/ethernet/engleder/tsnep_main.c    |   2 +-
 .../net/ethernet/freescale/dpaa2/dpaa2-xsk.c  |   2 +-
 drivers/net/ethernet/intel/i40e/i40e_xsk.c    |   2 +-
 drivers/net/ethernet/intel/ice/ice_xsk.c      |   2 +-
 drivers/net/ethernet/intel/igc/igc_main.c     |   2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c  |   2 +-
 .../ethernet/mellanox/mlx5/core/en/xsk/rx.c   |   4 +-
 .../net/ethernet/mellanox/mlx5/core/en_rx.c   |   2 +-
 drivers/net/ethernet/netronome/nfp/nfd3/xsk.c |   2 +-
 .../net/ethernet/stmicro/stmmac/stmmac_main.c |   2 +-
 kernel/dma/mapping.c                          |  60 ++++++++---
 kernel/dma/swiotlb.c                          |  14 +++
 net/core/page_pool.c                          |  67 +++++++-----
 net/xdp/xsk_buff_pool.c                       |  29 +----
 23 files changed, 237 insertions(+), 125 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2024-01-31 17:14 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-26 13:54 [PATCH net-next 0/7] dma: skip calling no-op sync ops when possible Alexander Lobakin
2024-01-26 13:54 ` [PATCH net-next 1/7] dma: compile-out DMA sync op calls when not used Alexander Lobakin
2024-01-29  6:11   ` Christoph Hellwig
2024-01-29 11:07     ` Alexander Lobakin
2024-01-29 12:15       ` Robin Murphy
2024-01-31 16:52   ` Simon Horman
2024-01-31 17:14     ` Robin Murphy
2024-01-26 13:54 ` [PATCH net-next 2/7] dma: avoid expensive redundant calls for sync operations Alexander Lobakin
2024-01-26 15:48   ` Robin Murphy
2024-01-26 16:45     ` Alexander Lobakin
2024-01-26 17:21       ` Robin Murphy
2024-01-26 18:48         ` Petr Tesařík
2024-01-26 19:13           ` Robin Murphy
2024-01-29  6:09             ` Christoph Hellwig
2024-01-29 14:36           ` Alexander Lobakin
2024-01-29 16:15             ` Petr Tesařík
2024-01-29 14:07       ` Alexander Lobakin
2024-01-29 14:29         ` Robin Murphy
2024-01-29 14:34           ` Alexander Lobakin
2024-01-26 13:54 ` [PATCH net-next 3/7] iommu/dma: avoid expensive indirect " Alexander Lobakin
2024-01-26 13:54 ` [PATCH net-next 4/7] page_pool: make sure frag API fields don't span between cachelines Alexander Lobakin
2024-01-26 13:54 ` [PATCH net-next 5/7] page_pool: don't use driver-set flags field directly Alexander Lobakin
2024-01-26 13:54 ` [PATCH net-next 6/7] page_pool: check for DMA sync shortcut earlier Alexander Lobakin
2024-01-26 13:54 ` [PATCH net-next 7/7] xsk: use generic DMA sync shortcut instead of a custom one Alexander Lobakin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).