linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH net-next v1 0/2] Minor cleanups to skb frag ref/unref
@ 2024-03-06 23:59 Mina Almasry
  2024-03-06 23:59 ` [RFC PATCH net-next v1 1/2] net: mirror skb frag ref/unref helpers Mina Almasry
  2024-03-06 23:59 ` [RFC PATCH net-next v1 2/2] net: remove napi_frag_[un]ref Mina Almasry
  0 siblings, 2 replies; 6+ messages in thread
From: Mina Almasry @ 2024-03-06 23:59 UTC (permalink / raw)
  To: netdev, linux-kernel, linux-rdma
  Cc: Mina Almasry, Mirko Lindner, Stephen Hemminger, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Tariq Toukan,
	Boris Pismenny, John Fastabend, Dragos Tatulea

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 <dtatulea@nvidia.com>

Mina Almasry (2):
  net: mirror skb frag ref/unref helpers
  net: remove napi_frag_[un]ref

 drivers/net/ethernet/marvell/sky2.c        |  2 +-
 drivers/net/ethernet/mellanox/mlx4/en_rx.c |  2 +-
 include/linux/skbuff.h                     | 45 +++++++++-------
 net/core/skbuff.c                          | 60 ++++++++--------------
 net/tls/tls_device.c                       |  2 +-
 net/tls/tls_strp.c                         |  2 +-
 6 files changed, 51 insertions(+), 62 deletions(-)

-- 
2.44.0.278.ge034bb2e1d-goog


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

end of thread, other threads:[~2024-03-07 12:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-06 23:59 [RFC PATCH net-next v1 0/2] Minor cleanups to skb frag ref/unref Mina Almasry
2024-03-06 23:59 ` [RFC PATCH net-next v1 1/2] net: mirror skb frag ref/unref helpers Mina Almasry
2024-03-07 10:44   ` Dragos Tatulea
2024-03-07 12:28   ` Yunsheng Lin
2024-03-06 23:59 ` [RFC PATCH net-next v1 2/2] net: remove napi_frag_[un]ref Mina Almasry
2024-03-07 11:08   ` Dragos Tatulea

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).