netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/4] net: introduce net_aligned_data
@ 2025-06-27 20:05 Eric Dumazet
  2025-06-27 20:05 ` [PATCH net-next 1/4] net: add struct net_aligned_data Eric Dumazet
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Eric Dumazet @ 2025-06-27 20:05 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, Willem de Bruijn, netdev, eric.dumazet,
	Eric Dumazet

____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"

...
ffffffff849dd480 B tcp_memory_allocated
ffffffff849dd488 B google_shared_statistics
ffffffff849dd4a0 b tcp_orphan_cache
ffffffff849dd4a4 b tcp_enable_tx_delay.__tcp_tx_delay_enabled
...
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


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 | 21 +++++++++++++++++++++
 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, 40 insertions(+), 19 deletions(-)
 create mode 100644 include/net/aligned_data.h

-- 
2.50.0.727.gbf7dc18ff4-goog


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

end of thread, other threads:[~2025-06-28 22:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-27 20:05 [PATCH net-next 0/4] net: introduce net_aligned_data Eric Dumazet
2025-06-27 20:05 ` [PATCH net-next 1/4] net: add struct net_aligned_data Eric Dumazet
2025-06-28 14:48   ` Willem de Bruijn
2025-06-27 20:05 ` [PATCH net-next 2/4] net: move net_cookie into net_aligned_data Eric Dumazet
2025-06-28 14:49   ` Willem de Bruijn
2025-06-28 20:19   ` kernel test robot
2025-06-27 20:05 ` [PATCH net-next 3/4] tcp: move tcp_memory_allocated " Eric Dumazet
2025-06-28 14:49   ` Willem de Bruijn
2025-06-28 22:14   ` kernel test robot
2025-06-27 20:05 ` [PATCH net-next 4/4] udp: move udp_memory_allocated " Eric Dumazet
2025-06-28 14:49   ` Willem de Bruijn

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