* [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
* [PATCH net-next 1/4] net: add struct net_aligned_data
2025-06-27 20:05 [PATCH net-next 0/4] net: introduce net_aligned_data Eric Dumazet
@ 2025-06-27 20:05 ` 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
` (2 subsequent siblings)
3 siblings, 1 reply; 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
This structure will hold networking data that must
consume a full cache line to avoid accidental false sharing.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/aligned_data.h | 16 ++++++++++++++++
net/core/hotdata.c | 3 +++
2 files changed, 19 insertions(+)
create mode 100644 include/net/aligned_data.h
diff --git a/include/net/aligned_data.h b/include/net/aligned_data.h
new file mode 100644
index 0000000000000000000000000000000000000000..cf3329d7c2272ec4424e89352626800cbc282663
--- /dev/null
+++ b/include/net/aligned_data.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef _NET_ALIGNED_DATA_H
+#define _NET_ALIGNED_DATA_H
+
+#include <linux/types.h>
+
+/* Structure holding cacheline aligned fields on SMP builds.
+ * Each field or group should have an ____cacheline_aligned_in_smp
+ * attribute to ensure no accidental false sharing can happen.
+ */
+struct net_aligned_data {
+};
+
+extern struct net_aligned_data net_aligned_data;
+
+#endif /* _NET_ALIGNED_DATA_H */
diff --git a/net/core/hotdata.c b/net/core/hotdata.c
index 0bc893d5f07b03b31e08967a2238f63d218020d7..e9c03491ab001cc85fd60ad28533649b32d8a003 100644
--- a/net/core/hotdata.c
+++ b/net/core/hotdata.c
@@ -2,6 +2,7 @@
#include <linux/cache.h>
#include <linux/jiffies.h>
#include <linux/list.h>
+#include <net/aligned_data.h>
#include <net/hotdata.h>
#include <net/proto_memory.h>
@@ -22,3 +23,5 @@ struct net_hotdata net_hotdata __cacheline_aligned = {
.sysctl_mem_pcpu_rsv = SK_MEMORY_PCPU_RESERVE
};
EXPORT_SYMBOL(net_hotdata);
+
+struct net_aligned_data net_aligned_data;
--
2.50.0.727.gbf7dc18ff4-goog
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 2/4] net: move net_cookie into net_aligned_data
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-27 20:05 ` 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-27 20:05 ` [PATCH net-next 4/4] udp: move udp_memory_allocated " Eric Dumazet
3 siblings, 2 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
Using per-cpu data for net->net_cookie generation is overkill,
because even busy hosts do not create hundreds of netns per second.
Make sure to put net_cookie in a private cache line to avoid
potential false sharing.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/aligned_data.h | 1 +
net/core/net_namespace.c | 8 ++------
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/include/net/aligned_data.h b/include/net/aligned_data.h
index cf3329d7c2272ec4424e89352626800cbc282663..6538c66efdf90ed51836cf244237ee17019a325d 100644
--- a/include/net/aligned_data.h
+++ b/include/net/aligned_data.h
@@ -9,6 +9,7 @@
* attribute to ensure no accidental false sharing can happen.
*/
struct net_aligned_data {
+ atomic64_t net_cookie ____cacheline_aligned_in_smp;
};
extern struct net_aligned_data net_aligned_data;
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index d0f607507ee8d0b6d31f11a49421b5f0a985bd3b..e68d208b200dd4be76fc08af73054b3d1dea834c 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -19,9 +19,9 @@
#include <linux/net_namespace.h>
#include <linux/sched/task.h>
#include <linux/uidgid.h>
-#include <linux/cookie.h>
#include <linux/proc_fs.h>
+#include <net/aligned_data.h>
#include <net/sock.h>
#include <net/netlink.h>
#include <net/net_namespace.h>
@@ -64,8 +64,6 @@ DECLARE_RWSEM(pernet_ops_rwsem);
static unsigned int max_gen_ptrs = INITIAL_NET_GEN_PTRS;
-DEFINE_COOKIE(net_cookie);
-
static struct net_generic *net_alloc_generic(void)
{
unsigned int gen_ptrs = READ_ONCE(max_gen_ptrs);
@@ -434,9 +432,7 @@ static __net_init int setup_net(struct net *net)
LIST_HEAD(net_exit_list);
int error = 0;
- preempt_disable();
- net->net_cookie = gen_cookie_next(&net_cookie);
- preempt_enable();
+ net->net_cookie = atomic64_inc_return(&net_aligned_data.net_cookie);
list_for_each_entry(ops, &pernet_list, list) {
error = ops_init(ops, net);
--
2.50.0.727.gbf7dc18ff4-goog
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 3/4] tcp: move tcp_memory_allocated into net_aligned_data
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-27 20:05 ` [PATCH net-next 2/4] net: move net_cookie into net_aligned_data Eric Dumazet
@ 2025-06-27 20:05 ` 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
3 siblings, 2 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 attribute only makes sure to align
a field to a cache line. It does not prevent the linker to use
the remaining of the cache line for other variables, causing
potential false sharing.
Move tcp_memory_allocated into a dedicated cache line.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/aligned_data.h | 3 +++
include/net/tcp.h | 1 -
net/core/hotdata.c | 2 ++
net/ipv4/tcp.c | 2 --
net/ipv4/tcp_ipv4.c | 3 ++-
net/ipv6/tcp_ipv6.c | 3 ++-
net/mptcp/protocol.c | 3 ++-
7 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/include/net/aligned_data.h b/include/net/aligned_data.h
index 6538c66efdf90ed51836cf244237ee17019a325d..a60c65a3b370a406b2078f23c3e332f58c84df58 100644
--- a/include/net/aligned_data.h
+++ b/include/net/aligned_data.h
@@ -10,6 +10,9 @@
*/
struct net_aligned_data {
atomic64_t net_cookie ____cacheline_aligned_in_smp;
+#if defined(CONFIG_INET)
+ atomic_long_t tcp_memory_allocated ____cacheline_aligned_in_smp;
+#endif
};
extern struct net_aligned_data net_aligned_data;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 761c4a0ad386f95f73d72dc013a0952187342b51..bc08de49805cf6fc2ffbec96e42bf12378fd10cf 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -267,7 +267,6 @@ extern long sysctl_tcp_mem[3];
#define TCP_RACK_STATIC_REO_WND 0x2 /* Use static RACK reo wnd */
#define TCP_RACK_NO_DUPTHRESH 0x4 /* Do not use DUPACK threshold in RACK */
-extern atomic_long_t tcp_memory_allocated;
DECLARE_PER_CPU(int, tcp_memory_per_cpu_fw_alloc);
extern struct percpu_counter tcp_sockets_allocated;
diff --git a/net/core/hotdata.c b/net/core/hotdata.c
index e9c03491ab001cc85fd60ad28533649b32d8a003..95d0a4df10069e4529fb9e5b58e8391574085cf1 100644
--- a/net/core/hotdata.c
+++ b/net/core/hotdata.c
@@ -4,6 +4,7 @@
#include <linux/list.h>
#include <net/aligned_data.h>
#include <net/hotdata.h>
+#include <net/ip.h>
#include <net/proto_memory.h>
struct net_hotdata net_hotdata __cacheline_aligned = {
@@ -25,3 +26,4 @@ struct net_hotdata net_hotdata __cacheline_aligned = {
EXPORT_SYMBOL(net_hotdata);
struct net_aligned_data net_aligned_data;
+EXPORT_IPV6_MOD(net_aligned_data);
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 8a3c99246d2ed32ba45849b56830bf128e265763..925b2c572ca23b3f2eba48a38820f6553a2724f4 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -302,8 +302,6 @@ EXPORT_PER_CPU_SYMBOL_GPL(tcp_tw_isn);
long sysctl_tcp_mem[3] __read_mostly;
EXPORT_IPV6_MOD(sysctl_tcp_mem);
-atomic_long_t tcp_memory_allocated ____cacheline_aligned_in_smp; /* Current allocated memory. */
-EXPORT_IPV6_MOD(tcp_memory_allocated);
DEFINE_PER_CPU(int, tcp_memory_per_cpu_fw_alloc);
EXPORT_PER_CPU_SYMBOL_GPL(tcp_memory_per_cpu_fw_alloc);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 429fb34b075e0bdad0e1c55dd6b1101b3dfe78dd..a9e1d19ffae4159fe1d6da4d2e8ee69e64f8dd55 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -59,6 +59,7 @@
#include <linux/slab.h>
#include <linux/sched.h>
+#include <net/aligned_data.h>
#include <net/net_namespace.h>
#include <net/icmp.h>
#include <net/inet_hashtables.h>
@@ -3391,7 +3392,7 @@ struct proto tcp_prot = {
.sockets_allocated = &tcp_sockets_allocated,
.orphan_count = &tcp_orphan_count,
- .memory_allocated = &tcp_memory_allocated,
+ .memory_allocated = &net_aligned_data.tcp_memory_allocated,
.per_cpu_fw_alloc = &tcp_memory_per_cpu_fw_alloc,
.memory_pressure = &tcp_memory_pressure,
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index f0ce62549d90d6492b8ab139640cca91e4a9c2c7..20d51941e58ae830ab254c4681cc95fd740b88df 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -41,6 +41,7 @@
#include <linux/random.h>
#include <linux/indirect_call_wrapper.h>
+#include <net/aligned_data.h>
#include <net/tcp.h>
#include <net/ndisc.h>
#include <net/inet6_hashtables.h>
@@ -2357,7 +2358,7 @@ struct proto tcpv6_prot = {
.stream_memory_free = tcp_stream_memory_free,
.sockets_allocated = &tcp_sockets_allocated,
- .memory_allocated = &tcp_memory_allocated,
+ .memory_allocated = &net_aligned_data.tcp_memory_allocated,
.per_cpu_fw_alloc = &tcp_memory_per_cpu_fw_alloc,
.memory_pressure = &tcp_memory_pressure,
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index e7972e633236e0451f0321ff4b0a8d1b37282d5f..5f904fc5ac4c63e8b6c7c9aa79f17e8dcdf1a007 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -11,6 +11,7 @@
#include <linux/netdevice.h>
#include <linux/sched/signal.h>
#include <linux/atomic.h>
+#include <net/aligned_data.h>
#include <net/sock.h>
#include <net/inet_common.h>
#include <net/inet_hashtables.h>
@@ -3729,7 +3730,7 @@ static struct proto mptcp_prot = {
.stream_memory_free = mptcp_stream_memory_free,
.sockets_allocated = &mptcp_sockets_allocated,
- .memory_allocated = &tcp_memory_allocated,
+ .memory_allocated = &net_aligned_data.tcp_memory_allocated,
.per_cpu_fw_alloc = &tcp_memory_per_cpu_fw_alloc,
.memory_pressure = &tcp_memory_pressure,
--
2.50.0.727.gbf7dc18ff4-goog
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 4/4] udp: move udp_memory_allocated into net_aligned_data
2025-06-27 20:05 [PATCH net-next 0/4] net: introduce net_aligned_data Eric Dumazet
` (2 preceding siblings ...)
2025-06-27 20:05 ` [PATCH net-next 3/4] tcp: move tcp_memory_allocated " Eric Dumazet
@ 2025-06-27 20:05 ` Eric Dumazet
2025-06-28 14:49 ` Willem de Bruijn
3 siblings, 1 reply; 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 attribute only makes sure to align
a field to a cache line. It does not prevent the linker to use
the remaining of the cache line for other variables, causing
potential false sharing.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/aligned_data.h | 1 +
include/net/udp.h | 1 -
net/ipv4/udp.c | 4 +---
net/ipv4/udp_impl.h | 1 +
net/ipv4/udplite.c | 2 +-
net/ipv6/udp.c | 2 +-
net/ipv6/udp_impl.h | 1 +
net/ipv6/udplite.c | 2 +-
8 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/include/net/aligned_data.h b/include/net/aligned_data.h
index a60c65a3b370a406b2078f23c3e332f58c84df58..fc07461e31352eb757c34867ea9b458fb9e539f4 100644
--- a/include/net/aligned_data.h
+++ b/include/net/aligned_data.h
@@ -12,6 +12,7 @@ struct net_aligned_data {
atomic64_t net_cookie ____cacheline_aligned_in_smp;
#if defined(CONFIG_INET)
atomic_long_t tcp_memory_allocated ____cacheline_aligned_in_smp;
+ atomic_long_t udp_memory_allocated ____cacheline_aligned_in_smp;
#endif
};
diff --git a/include/net/udp.h b/include/net/udp.h
index a772510b2aa58a922dc4dd5bd7cb7f7f0c1ce0e3..f8ae2c4ade141d27e4af3376f5a177e46d5b39ea 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -205,7 +205,6 @@ static inline void udp_hash4_dec(struct udp_hslot *hslot2)
extern struct proto udp_prot;
-extern atomic_long_t udp_memory_allocated;
DECLARE_PER_CPU(int, udp_memory_per_cpu_fw_alloc);
/* sysctl variables for udp */
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 19573ee64a0f18cf55df34ace1956e9c3e20172c..49f43c54cfb0e3ac85c1a6202f3d6a2f1ca6d0ba 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -127,8 +127,6 @@ struct udp_table udp_table __read_mostly;
long sysctl_udp_mem[3] __read_mostly;
EXPORT_IPV6_MOD(sysctl_udp_mem);
-atomic_long_t udp_memory_allocated ____cacheline_aligned_in_smp;
-EXPORT_IPV6_MOD(udp_memory_allocated);
DEFINE_PER_CPU(int, udp_memory_per_cpu_fw_alloc);
EXPORT_PER_CPU_SYMBOL_GPL(udp_memory_per_cpu_fw_alloc);
@@ -3235,7 +3233,7 @@ struct proto udp_prot = {
#ifdef CONFIG_BPF_SYSCALL
.psock_update_sk_prot = udp_bpf_update_proto,
#endif
- .memory_allocated = &udp_memory_allocated,
+ .memory_allocated = &net_aligned_data.udp_memory_allocated,
.per_cpu_fw_alloc = &udp_memory_per_cpu_fw_alloc,
.sysctl_mem = sysctl_udp_mem,
diff --git a/net/ipv4/udp_impl.h b/net/ipv4/udp_impl.h
index e1ff3a37599614b18a0b621534019a7bd71ea901..c7142213fc2112c9e423caa5e6d84bafeaca9936 100644
--- a/net/ipv4/udp_impl.h
+++ b/net/ipv4/udp_impl.h
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _UDP4_IMPL_H
#define _UDP4_IMPL_H
+#include <net/aligned_data.h>
#include <net/udp.h>
#include <net/udplite.h>
#include <net/protocol.h>
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c
index af37af3ab727bffeebe5c41d84cb7c130f49c50d..d3e621a11a1aa4cafb62eb53ddc0ed1ca517a7fe 100644
--- a/net/ipv4/udplite.c
+++ b/net/ipv4/udplite.c
@@ -60,7 +60,7 @@ struct proto udplite_prot = {
.rehash = udp_v4_rehash,
.get_port = udp_v4_get_port,
- .memory_allocated = &udp_memory_allocated,
+ .memory_allocated = &net_aligned_data.udp_memory_allocated,
.per_cpu_fw_alloc = &udp_memory_per_cpu_fw_alloc,
.sysctl_mem = sysctl_udp_mem,
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index ebb95d8bc6819f72842fd1567e73fcef4f1e0ed0..6bbdadbd5fecccfb7de99f05c6fb179393e162f2 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1925,7 +1925,7 @@ struct proto udpv6_prot = {
.psock_update_sk_prot = udp_bpf_update_proto,
#endif
- .memory_allocated = &udp_memory_allocated,
+ .memory_allocated = &net_aligned_data.udp_memory_allocated,
.per_cpu_fw_alloc = &udp_memory_per_cpu_fw_alloc,
.sysctl_mem = sysctl_udp_mem,
diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h
index 0590f566379d7d07dfdd1b0ae808b9d8964eb5aa..8a406be25a3a6dee687a6a02ea0b6a28428abb86 100644
--- a/net/ipv6/udp_impl.h
+++ b/net/ipv6/udp_impl.h
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _UDP6_IMPL_H
#define _UDP6_IMPL_H
+#include <net/aligned_data.h>
#include <net/udp.h>
#include <net/udplite.h>
#include <net/protocol.h>
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c
index a60bec9b14f14a5b2d271f9965b5fca3d2a440c8..2cec542437f74eba9540fc464ee70d8b0bc0be79 100644
--- a/net/ipv6/udplite.c
+++ b/net/ipv6/udplite.c
@@ -59,7 +59,7 @@ struct proto udplitev6_prot = {
.rehash = udp_v6_rehash,
.get_port = udp_v6_get_port,
- .memory_allocated = &udp_memory_allocated,
+ .memory_allocated = &net_aligned_data.udp_memory_allocated,
.per_cpu_fw_alloc = &udp_memory_per_cpu_fw_alloc,
.sysctl_mem = sysctl_udp_mem,
--
2.50.0.727.gbf7dc18ff4-goog
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 1/4] net: add struct net_aligned_data
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
0 siblings, 0 replies; 11+ messages in thread
From: Willem de Bruijn @ 2025-06-28 14:48 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Willem de Bruijn, netdev, eric.dumazet,
Eric Dumazet
Eric Dumazet wrote:
> This structure will hold networking data that must
> consume a full cache line to avoid accidental false sharing.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 2/4] net: move net_cookie into net_aligned_data
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
1 sibling, 0 replies; 11+ messages in thread
From: Willem de Bruijn @ 2025-06-28 14:49 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Willem de Bruijn, netdev, eric.dumazet,
Eric Dumazet
Eric Dumazet wrote:
> Using per-cpu data for net->net_cookie generation is overkill,
> because even busy hosts do not create hundreds of netns per second.
>
> Make sure to put net_cookie in a private cache line to avoid
> potential false sharing.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 3/4] tcp: move tcp_memory_allocated into net_aligned_data
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
1 sibling, 0 replies; 11+ messages in thread
From: Willem de Bruijn @ 2025-06-28 14:49 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Willem de Bruijn, netdev, eric.dumazet,
Eric Dumazet
Eric Dumazet wrote:
> ____cacheline_aligned_in_smp attribute only makes sure to align
> a field to a cache line. It does not prevent the linker to use
> the remaining of the cache line for other variables, causing
> potential false sharing.
>
> Move tcp_memory_allocated into a dedicated cache line.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 4/4] udp: move udp_memory_allocated into net_aligned_data
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
0 siblings, 0 replies; 11+ messages in thread
From: Willem de Bruijn @ 2025-06-28 14:49 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Willem de Bruijn, netdev, eric.dumazet,
Eric Dumazet
Eric Dumazet wrote:
> ____cacheline_aligned_in_smp attribute only makes sure to align
> a field to a cache line. It does not prevent the linker to use
> the remaining of the cache line for other variables, causing
> potential false sharing.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 2/4] net: move net_cookie into net_aligned_data
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
1 sibling, 0 replies; 11+ messages in thread
From: kernel test robot @ 2025-06-28 20:19 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: oe-kbuild-all, Simon Horman, Willem de Bruijn, netdev,
eric.dumazet, Eric Dumazet
Hi Eric,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/net-add-struct-net_aligned_data/20250628-040753
base: net-next/main
patch link: https://lore.kernel.org/r/20250627200551.348096-3-edumazet%40google.com
patch subject: [PATCH net-next 2/4] net: move net_cookie into net_aligned_data
config: riscv-randconfig-002-20250629 (https://download.01.org/0day-ci/archive/20250629/202506290617.ImmLRhZL-lkp@intel.com/config)
compiler: riscv32-linux-gcc (GCC) 13.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250629/202506290617.ImmLRhZL-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202506290617.ImmLRhZL-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from net/core/hotdata.c:5:
>> include/net/aligned_data.h:12:9: error: unknown type name 'atomic64_t'
12 | atomic64_t net_cookie ____cacheline_aligned_in_smp;
| ^~~~~~~~~~
vim +/atomic64_t +12 include/net/aligned_data.h
6
7 /* Structure holding cacheline aligned fields on SMP builds.
8 * Each field or group should have an ____cacheline_aligned_in_smp
9 * attribute to ensure no accidental false sharing can happen.
10 */
11 struct net_aligned_data {
> 12 atomic64_t net_cookie ____cacheline_aligned_in_smp;
13 };
14
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 3/4] tcp: move tcp_memory_allocated into net_aligned_data
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
1 sibling, 0 replies; 11+ messages in thread
From: kernel test robot @ 2025-06-28 22:14 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: oe-kbuild-all, Simon Horman, Willem de Bruijn, netdev,
eric.dumazet, Eric Dumazet
Hi Eric,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/net-add-struct-net_aligned_data/20250628-040753
base: net-next/main
patch link: https://lore.kernel.org/r/20250627200551.348096-4-edumazet%40google.com
patch subject: [PATCH net-next 3/4] tcp: move tcp_memory_allocated into net_aligned_data
config: riscv-randconfig-002-20250629 (https://download.01.org/0day-ci/archive/20250629/202506290837.0mGwXgmy-lkp@intel.com/config)
compiler: riscv32-linux-gcc (GCC) 13.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250629/202506290837.0mGwXgmy-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202506290837.0mGwXgmy-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from net/core/hotdata.c:5:
include/net/aligned_data.h:12:9: error: unknown type name 'atomic64_t'
12 | atomic64_t net_cookie ____cacheline_aligned_in_smp;
| ^~~~~~~~~~
>> include/net/aligned_data.h:14:9: error: unknown type name 'atomic_long_t'
14 | atomic_long_t tcp_memory_allocated ____cacheline_aligned_in_smp;
| ^~~~~~~~~~~~~
vim +/atomic_long_t +14 include/net/aligned_data.h
6
7 /* Structure holding cacheline aligned fields on SMP builds.
8 * Each field or group should have an ____cacheline_aligned_in_smp
9 * attribute to ensure no accidental false sharing can happen.
10 */
11 struct net_aligned_data {
12 atomic64_t net_cookie ____cacheline_aligned_in_smp;
13 #if defined(CONFIG_INET)
> 14 atomic_long_t tcp_memory_allocated ____cacheline_aligned_in_smp;
15 #endif
16 };
17
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ 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).