Skip to content

Minor cleanups to skb frag ref/unref

Mina Almasry linux-rdma lkml netdev 6 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest2 patches 0 repliesApplied 2/2
  2. v53 patches 5 repliesSuperseded 2 of 3 applied
  3. v43 patches 3 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v33 patches1 replySuperseded
v23 patches0 repliesSuperseded
v1 RFC2 patches3 repliesSuperseded

Changes in v6 from the cover letter

- Rebased on top of net-next; dropped the merged patches.
- Move skb ref helpers to a new header file. (Jakub).

Patches in v6 All 2 applied

#Subject and filesSizeRepliesApplied
1/2net: move skb ref helpers to new headerdrivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c drivers/net/ethernet/marvell/sky2.c drivers/net/ethernet/mellanox/mlx4/en_rx.c +13 more+89 -630 repliesApplied
2/2net: mirror skb frag ref/unref helpersdrivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c drivers/net/ethernet/sun/cassini.c drivers/net/veth.c +3 more+44 -510 repliesApplied

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchDragos TatuleaJacob Keller
1/2
2/2R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [PATCH net-next v6 0/2] Minor cleanups to skb frag ref/unref

v6:
- Rebased on top of net-next; dropped the merged patches.
- Move skb ref helpers to a new header file. (Jakub).

v5:
- Applied feedback from Eric to inline napi_pp_get_page().
- Applied Reviewed-By's.

v4:
- Rebased to net-next.
- Clarified skb_shift() code change in commit message.
- Use skb->pp_recycle in a couple of places where I previously hardcoded 'false'.

v3:
- Fixed patchwork build errors/warnings from patch-by-patch modallconfig build

v2:
- Removed RFC tag.
- Rebased on net-next after the merge window opening.
- Added 1 patch at the beginning, "net: make napi_frag_unref reuse skb_page_unref" because a recent patch introduced some code duplication that can also be improved.
- Addressed feedback from Dragos & Yunsheng.
- Added Dragos's Reviewed-by.

This series is largely motivated by a recent discussion where there was some confusion on how to properly ref/unref pp pages vs non pp pages:

https://lore.kernel.org/netdev/CAHS8izOoO-EovwMwAm9tLYetwikNPxC0FKyVGu1TPJWSz4bGoA@mail.gmail.com/T/#t

There is some subtely there because pp uses page->pp_ref_count for refcounting, while non-pp uses get_page()/put_page() for ref counting. Getting the refcounting pairs wrong can lead to kernel crash.

Additionally currently it may not be obvious to skb users unaware of page pool internals how to properly acquire a ref on a pp frag. It requires checking of skb->pp_recycle & is_pp_page() to make the correct calls and may require some handling at the call site aware of arguable pp internals.

This series is a minor refactor with a couple of goals:

1. skb users should be able to ref/unref a frag using [__]skb_frag_[un]ref() functions without needing to understand pp concepts and pp_ref_count vs get/put_page() differences.

2. reference counting functions should have a mirror opposite. I.e. there should be a foo_unref() to every foo_ref() with a mirror opposite implementation (as much as possible).

This is RFC to collect feedback if this change is desirable, but also so that I don't race with the fix for the issue Dragos is seeing for his crash.

https://lore.kernel.org/lkml/CAHS8izN436pn3SndrzsCyhmqvJHLyxgCeDpWXA4r1ANt3RCDLQ@mail.gmail.com/T/

Cc Dragos Tatulea <[email protected]>

Mina Almasry (2):
net: move skb ref helpers to new header
net: mirror skb frag ref/unref helpers

 .../chelsio/inline_crypto/ch_ktls/chcr_ktls.c |   3 +-
 drivers/net/ethernet/marvell/sky2.c           |   1 +
 drivers/net/ethernet/mellanox/mlx4/en_rx.c    |   1 +
 drivers/net/ethernet/sun/cassini.c            |   5 +-
 drivers/net/veth.c                            |   3 +-
 drivers/net/xen-netback/netback.c             |   1 +
 include/linux/skbuff.h                        |  63 -----------
 include/linux/skbuff_ref.h                    | 106 ++++++++++++++++++
 net/core/gro.c                                |   1 +
 net/core/skbuff.c                             |  47 +-------
 net/ipv4/esp4.c                               |   1 +
 net/ipv4/tcp_output.c                         |   1 +
 net/ipv6/esp6.c                               |   1 +
 net/tls/tls_device.c                          |   1 +
 net/tls/tls_device_fallback.c                 |   3 +-
 net/tls/tls_strp.c                            |   1 +
 16 files changed, 129 insertions(+), 110 deletions(-)
 create mode 100644 include/linux/skbuff_ref.h
Signature · 1 line
2.44.0.478.gd926399ef9-goog