Skip to content

RFC udp: avoid false sharing on sk_tsflags

Paolo Abeni netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2sock: introduce set_tsflags operationinclude/net/sock.h include/net/tcp.h net/core/sock.c +3 more+29 -150 replies
2/2udp: avoid false sharing via protocol specific set_tsflagsinclude/linux/udp.h include/net/sock.h net/ipv4/udp.c +1 more+26 -60 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [RFC PATCH 0/2] udp: avoid false sharing on sk_tsflags

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(-)
Signature · 1 line
2.48.1