[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250630093540.3052835-1-edumazet@google.com>
Date: Mon, 30 Jun 2025 09:35:36 +0000
From: Eric Dumazet <edumazet@...gle.com>
To: "David S . Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: Simon Horman <horms@...nel.org>, Willem de Bruijn <willemb@...gle.com>, netdev@...r.kernel.org,
eric.dumazet@...il.com, Eric Dumazet <edumazet@...gle.com>
Subject: [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 <lkp@...el.com>
v1: https://lore.kernel.org/netdev/20250627200551.348096-1-edumazet@google.com/
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
--
2.50.0.727.gbf7dc18ff4-goog
Powered by blists - more mailing lists