netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] udp: avoid false sharing on sk_tsflags
@ 2025-02-07 16:23 Paolo Abeni
  2025-02-07 16:23 ` [RFC PATCH 1/2] sock: introduce set_tsflags operation Paolo Abeni
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Paolo Abeni @ 2025-02-07 16:23 UTC (permalink / raw)
  To: netdev
  Cc: Willem de Bruijn, Eric Dumazet, Kuniyuki Iwashima,
	David S. Miller, Jakub Kicinski, Simon Horman, Neal Cardwell,
	David Ahern

While benchmarking the recently shared page frag revert, I observed a
lot of cache misses in the UDP RX path due to false sharing between the
sk_tsflags and the sk_forward_alloc sk fields.

Here comes a solution attempt for such a problem, inspired by commit
f796feabb9f5 ("udp: add local "peek offset enabled" flag").

The first patch adds a new proto op allowing protocol specific operation
on tsflags updates, and the 2nd one leverages such operation to cache
the problematic field in a cache friendly manner.

The need for a new operation is possibly suboptimal, hence the RFC tag,
but I could not find other good solutions. I considered:
- moving the sk_tsflags just before 'sk_policy', in the 'sock_read_rxtx'
  group. It arguably belongs to such group, but the change would create
  a couple of holes, increasing the 'struct sock' size and would have 
  side effects on other protocols
- moving the sk_tsflags just before 'sk_stamp'; similar to the above,
  would possibly reduce the side effects, as most of 'struct sock'
  layout will be unchanged. Could increase the number of cacheline
  accessed in the TX path.

I opted for the present solution as it should minimize the side effects
to other protocols.

Paolo Abeni (2):
  sock: introduce set_tsflags operation
  udp: avoid false sharing via protocol specific set_tsflags

 include/linux/udp.h | 12 ++++++++++++
 include/net/sock.h  | 15 +++++++++++----
 include/net/tcp.h   |  1 +
 net/core/sock.c     | 24 +++++++++---------------
 net/ipv4/tcp.c      | 16 ++++++++++++++++
 net/ipv4/tcp_ipv4.c |  1 +
 net/ipv4/udp.c      |  3 ++-
 net/ipv6/tcp_ipv6.c |  1 +
 net/ipv6/udp.c      |  3 ++-
 9 files changed, 55 insertions(+), 21 deletions(-)

-- 
2.48.1


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

end of thread, other threads:[~2025-02-11  3:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-07 16:23 [RFC PATCH 0/2] udp: avoid false sharing on sk_tsflags Paolo Abeni
2025-02-07 16:23 ` [RFC PATCH 1/2] sock: introduce set_tsflags operation Paolo Abeni
2025-02-07 16:23 ` [RFC PATCH 2/2] udp: avoid false sharing via protocol specific set_tsflags Paolo Abeni
2025-02-10  4:00 ` [RFC PATCH 0/2] udp: avoid false sharing on sk_tsflags Willem de Bruijn
2025-02-10 15:13   ` Eric Dumazet
2025-02-10 16:16     ` Paolo Abeni
2025-02-10 16:37       ` Eric Dumazet
2025-02-10 17:53         ` Willem de Bruijn
2025-02-10 20:54           ` Paolo Abeni
2025-02-10 21:24       ` Paolo Abeni
2025-02-10 21:26         ` Eric Dumazet
2025-02-11  3:16           ` Willem de Bruijn
2025-02-10 21:33         ` Eric Dumazet
2025-02-10  7:49 ` Eric Dumazet

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