Skip to content

net: introduce net_aligned_data

Eric Dumazet netdev 2 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. v2 Latest4 patches 0 repliesApplied 4/4
  2. v14 patches 4 repliesSuperseded

Patches in v2 All 4 applied

#Subject and filesSizeRepliesApplied
1/4net: add struct net_aligned_datainclude/net/aligned_data.h net/core/hotdata.c+19 -00 repliesApplied
2/4net: move net_cookie into net_aligned_datainclude/net/aligned_data.h net/core/net_namespace.c+4 -60 repliesApplied
3/4tcp: move tcp_memory_allocated into net_aligned_datainclude/net/aligned_data.h include/net/tcp.h net/core/hotdata.c +4 more+11 -60 repliesApplied
4/4udp: move udp_memory_allocated into net_aligned_datainclude/net/aligned_data.h include/net/udp.h net/ipv4/udp.c +5 more+7 -70 repliesApplied

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchWillem de Bruijn
1/4R-b
2/4R-b
3/4R-b
4/4R-b

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

Read the v2 thread

Cover letter [PATCH v2 net-next 0/4] net: introduce net_aligned_data

____cacheline_aligned_in_smp on small fields like tcp_memory_allocated and udp_memory_allocated is not good enough.

It makes sure to put these fields at the start of a cache line, but does not prevent the linker from using the cache line for other fields, with potential performance impact.

nm -v vmlinux|egrep -5 "tcp_memory_allocated|udp_memory_allocated"

...
ffffffff83e35cc0 B tcp_memory_allocated
ffffffff83e35cc8 b __key.0
ffffffff83e35cc8 b __tcp_tx_delay_enabled.1
ffffffff83e35ce0 b tcp_orphan_timer
...
ffffffff849dddc0 B udp_memory_allocated
ffffffff849dddc8 B udp_encap_needed_key
ffffffff849dddd8 B udpv6_encap_needed_key
ffffffff849dddf0 b inetsw_lock

One solution is to move these sensitive fields to a structure, so that the compiler is forced to add empty holes between each member.

nm -v vmlinux|egrep -2 "tcp_memory_allocated|udp_memory_allocated|net_aligned_data"

ffffffff885af970 b mem_id_init
ffffffff885af980 b __key.0
ffffffff885af9c0 B net_aligned_data
ffffffff885afa80 B page_pool_mem_providers
ffffffff885afa90 b __key.2

v2: added <linux/atomic.h>, report from kernel test robot <[email protected]>
v1: https://lore.kernel.org/netdev/[email protected]/

Eric Dumazet (4):
net: add struct net_aligned_data
net: move net_cookie into net_aligned_data
tcp: move tcp_memory_allocated into net_aligned_data
udp: move udp_memory_allocated into net_aligned_data

 include/net/aligned_data.h | 22 ++++++++++++++++++++++
 include/net/tcp.h          |  1 -
 include/net/udp.h          |  1 -
 net/core/hotdata.c         |  5 +++++
 net/core/net_namespace.c   |  8 ++------
 net/ipv4/tcp.c             |  2 --
 net/ipv4/tcp_ipv4.c        |  3 ++-
 net/ipv4/udp.c             |  4 +---
 net/ipv4/udp_impl.h        |  1 +
 net/ipv4/udplite.c         |  2 +-
 net/ipv6/tcp_ipv6.c        |  3 ++-
 net/ipv6/udp.c             |  2 +-
 net/ipv6/udp_impl.h        |  1 +
 net/ipv6/udplite.c         |  2 +-
 net/mptcp/protocol.c       |  3 ++-
 15 files changed, 41 insertions(+), 19 deletions(-)
 create mode 100644 include/net/aligned_data.h
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog