Skip to content

Clean up RX copybreak and DMA handling

Michał Mirosław ath9k-devel linux-mips linux-wireless netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest16 of 46 patches 17 repliesIn review

16 of 46 patches are in this archive. The cover letter announces 46.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/46net: introduce __netdev_alloc_skb_aligned()include/linux/skbuff.h+27 -04 replies
2/46net: wrap common patterns of rx handler codeinclude/linux/skbuff.h+142 -00 replies
3/46net drivers: remove unnecessary dma_sync_to_device(DMA_FROM_DEVICE)drivers/net/arm/ep93xx_eth.c drivers/net/b44.c drivers/net/bnx2.c +15 more+2 -903 replies
4/46net/wireless: p54: remove useless dma_sync_single_for_device(DMA_FROM_DEVICE)drivers/net/wireless/p54/p54pci.c drivers/net/wireless/p54/txrx.c+11 -132 replies
5/46net: bnx2x: fix DMA sync directiondrivers/net/bnx2x/bnx2x_cmn.c drivers/net/bnx2x/bnx2x_ethtool.c+2 -20 replies
6/46net/tokenring: 3c359: fix DMA API usagedrivers/net/tokenring/3c359.c drivers/net/tokenring/3c359.h+32 -210 replies
8/46net/wireless: b43: fix DMA direction for RX buffersdrivers/net/wireless/b43/dma.c+5 -40 replies
9/46net: octeon_mgmt: fix DMA unmap sizedrivers/net/octeon/octeon_mgmt.c+4 -50 replies
10/46net: jme: convert to generic DMA APIdrivers/net/jme.c+12 -250 replies
11/46net: sungem: cleanup RX skb allocationdrivers/net/sungem.c drivers/net/sungem.h+14 -240 replies
12/46net: sunhme: cleanup RX skb allocationdrivers/net/sunhme.c drivers/net/sunhme.h+9 -230 replies
13/46net: sunbmac: cleanup RX skb allocationdrivers/net/sunbmac.c drivers/net/sunbmac.h+12 -280 replies
14/46net: sunbmac: cleanup magic '34'drivers/net/sunbmac.c+14 -180 replies
15/46net/wireless: b43: use kfree_skb() for untouched skbsdrivers/net/wireless/b43/dma.c+3 -30 replies
16/46net: cxgb3: don't drop packets on memory pressure in driverdrivers/net/cxgb3/sge.c+2 -60 replies
46/46net: mark drivers that drop packets from rx queue head under memory pressuredrivers/net/arm/ep93xx_eth.c drivers/net/bnx2.c drivers/net/bnx2x/bnx2x_cmn.c +9 more+36 -05 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 00/46] Clean up RX copybreak and DMA handling

Quick rx_copybreak cleaning turned out to rise more dust around...

Most drivers use dma_sync_single_to_device() for buffers that are written only by device. That's probably because of bad example in current Documentation/DMA-API-HOWTO.txt. Why is it bad? It unnecessarily flushes cachelines and CPU write buffers for memory that is not used by the hardware. Documentation/DMA-API.txt (part Id) describes exactly when streaming DMA buffers should be synced and in which direction. Syncing DMA_FROM_DEVICE mappings for device is not among them.

A lot of drivers drop packets already DMA'd in on memory pressure. This is suboptimal:
1. under packet storm and memory pressure NIC keeps generating interrupts (if non-NAPI) and indicating new buffers because it always has free RX buffers --- this only wastes CPU and bus bandwidth transferring data that is going to be immediately discarded;
2. for users of swap over network (NBD, NFS - assumming those get fixed, or maybe FCoE?) this can cause deadlock if the packets (acks maybe?) are needed to reclaim memory.

It unlikely that you'll ever hit the dark scenarios above, but if you do you'll have a hard time debugging.

Menu:
1..2:
wrap code commonly used in drivers into generic functions
3..4:
remove dma_sync_to_device(DMA_FROM_DEVICE) from drivers not converted to common rx handling functions
5..10:
fix various DMA API usage bugs in rx handling code
11..14:
clean up rx buffer allocation in sun* drivers
15:
b43: use kfree_skb() if the skb is known not to have been used
16:
cxgb3: remove code dropping packets on memory pressure in driver
46:
mark some drivers that drop packets from rx queue head when under memory pressure

Left out for later:
17..34:
convert multiple drivers to common rx_copybreak handling
35..45:
convert multiple drivers to common rx_copybreak handling; those drivers drop rxed packets when under memory pressure

Patches 17..45 are more-or-less templated and in the same spirit as the earlier version.
[davem: I plan send them after/if you agree to take patch 2. Or earlier, if you want them all at once anyway.]

Best Regards,
Michał Mirosław

---

Michał Mirosław (46):
net: introduce __netdev_alloc_skb_aligned()
net: wrap common patterns of rx handler code
net drivers: remove unnecessary dma_sync_to_device(DMA_FROM_DEVICE) net/wireless: p54: remove useless
dma_sync_single_for_device(DMA_FROM_DEVICE)
net: bnx2x: fix DMA sync direction
net/tokenring: 3c359: fix DMA API usage
net/wireless: ath9k: fix DMA API usage
net/wireless: b43: fix DMA direction for RX buffers
net: octeon_mgmt: fix DMA unmap size
net: jme: convert to generic DMA API
net: sungem: cleanup RX skb allocation
net: sunhme: cleanup RX skb allocation
net: sunbmac: cleanup RX skb allocation
net: sunbmac: cleanup magic '34'
net/wireless: b43: use kfree_skb() for untouched skbs
net: cxgb3: don't drop packets on memory pressure in driver
net: 3c59x: use common rx_copybreak handling
net: epic100: use common rx_copybreak handling
net: fealnx: use common rx_copybreak handling
net: hamachi: use common rx_copybreak handling
net: bcm63xx: use common rx_copybreak handling
net: chelsio: use common rx_copybreak handling
net: cxgb3: use common rx_copybreak handling
net: dl2k: use common rx_copybreak handling
net: natsemi: use common rx_copybreak handling
net: sis190: use common rx_copybreak handling
net: starfire: use common rx_copybreak handling
net: sundance: use common rx_copybreak handling
net: tulip/interrupt: use common rx_copybreak handling
net: tulip/winbond-840: use common rx_copybreak handling
net: typhoon: use common rx_copybreak handling
net: via-rhine: use common rx_copybreak handling
net: via-velocity: use common rx_copybreak handling
net: yellowfin: use common rx_copybreak handling
net: lib82596: use common rx_copybreak handling [strict refill!]
net: pcnet32: use common rx_copybreak handling [strict refill!]
net: sgiseeq: use common rx_copybreak handling [strict refill!]
net: tulip/de2104x: use common rx_copybreak handling [strict refill!]
net: sunhme: use common rx_copybreak handling [strict refill!]
net: sunbmac: use common rx_copybreak handling [strict refill!]
net: rrunner: use common rx_copybreak handling [strict refill!]
net: greth: use common rx_copybreak handling [strict refill!]
net: sunbmac: use common rx_copybreak handling [strict refill!]
net: tokenring/3c359: use common rx_copybreak handling [strict
refill!]
net/wireless: adm8211: use common rx_copybreak handling [strict
refill!]
net: mark drivers that drop packets from rx queue head under memory
pressure

 drivers/net/3c59x.c                         |   23 +---
 drivers/net/arm/ep93xx_eth.c                |    6 +-
 drivers/net/b44.c                           |    4 -
 drivers/net/bcm63xx_enet.c                  |   28 +----
 drivers/net/bnx2.c                          |    7 +-
 drivers/net/bnx2x/bnx2x_cmn.c               |    5 +-
 drivers/net/bnx2x/bnx2x_cmn.h               |    5 -
 drivers/net/bnx2x/bnx2x_ethtool.c           |    2 +-
 drivers/net/cassini.c                       |   15 +--
 drivers/net/chelsio/sge.c                   |   42 +------
 drivers/net/cxgb3/sge.c                     |   57 ++-------
 drivers/net/dl2k.c                          |   28 +----
 drivers/net/e100.c                          |    3 -
 drivers/net/e1000e/netdev.c                 |    4 +-
 drivers/net/epic100.c                       |   32 ++----
 drivers/net/fealnx.c                        |   40 ++-----
 drivers/net/greth.c                         |   67 ++++-------
 drivers/net/hamachi.c                       |   42 +------
 drivers/net/jme.c                           |   40 +++----
 drivers/net/lib82596.c                      |   70 +++--------
 drivers/net/mlx4/en_rx.c                    |    8 +-
 drivers/net/natsemi.c                       |   37 ++-----
 drivers/net/octeon/octeon_mgmt.c            |    9 +-
 drivers/net/pcnet32.c                       |   53 ++-------
 drivers/net/qlge/qlge_main.c                |   11 --
 drivers/net/r8169.c                         |    4 +-
 drivers/net/rrunner.c                       |   66 +++--------
 drivers/net/s2io.c                          |    6 +-
 drivers/net/sgiseeq.c                       |   42 +++-----
 drivers/net/sis190.c                        |   40 +------
 drivers/net/skge.c                          |    6 +-
 drivers/net/sky2.c                          |    4 +-
 drivers/net/starfire.c                      |   28 ++---
 drivers/net/sunbmac.c                       |   78 +++----------
 drivers/net/sunbmac.h                       |   18 +---
 drivers/net/sundance.c                      |   26 +---
 drivers/net/sungem.c                        |   84 +++----------
 drivers/net/sungem.h                        |    4 +-
 drivers/net/sunhme.c                        |   61 ++--------
 drivers/net/sunhme.h                        |   14 +--
 drivers/net/tg3.c                           |    3 +-
 drivers/net/tokenring/3c359.c               |   74 ++++++------
 drivers/net/tokenring/3c359.h               |    4 +-
 drivers/net/tokenring/olympic.c             |    8 +-
 drivers/net/tulip/de2104x.c                 |   39 ++-----
 drivers/net/tulip/interrupt.c               |   77 +++----------
 drivers/net/tulip/winbond-840.c             |   28 +----
 drivers/net/typhoon.c                       |   26 +---
 drivers/net/via-rhine.c                     |   38 +-----
 drivers/net/via-velocity.c                  |   61 ++--------
 drivers/net/vxge/vxge-main.c                |    6 +-
 drivers/net/wireless/adm8211.c              |   41 +------
 drivers/net/wireless/ath/ath9k/ar9003_mac.c |    4 +-
 drivers/net/wireless/ath/ath9k/ar9003_mac.h |    2 +-
 drivers/net/wireless/ath/ath9k/recv.c       |   10 +-
 drivers/net/wireless/b43/dma.c              |   15 ++-
 drivers/net/wireless/b43legacy/dma.c        |   19 ---
 drivers/net/wireless/p54/p54pci.c           |    2 -
 drivers/net/wireless/p54/txrx.c             |   22 ++--
 drivers/net/yellowfin.c                     |   27 +----
 include/linux/skbuff.h                      |  169 +++++++++++++++++++++++++++
 61 files changed, 586 insertions(+), 1208 deletions(-)
Signature · 1 line
1.7.5.4