Commit e3d48251 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski
Browse files

udp: move udp_memory_allocated into net_aligned_data



____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: default avatarEric Dumazet <edumazet@google.com>
Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20250630093540.3052835-5-edumazet@google.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 83081337
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,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
};

+0 −1
Original line number Diff line number Diff line
@@ -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 */
+1 −3
Original line number Diff line number Diff line
@@ -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,
+1 −0
Original line number Diff line number Diff line
/* 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>
+1 −1
Original line number Diff line number Diff line
@@ -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,
Loading