net: cache align tcp_memory_allocated, tcp_sockets_allocated

tcp_memory_allocated and tcp_sockets_allocated often share
a common cache line, source of false sharing.

Also take care of udp_memory_allocated and mptcp_sockets_allocated.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Eric Dumazet 2021-11-15 11:02:39 -08:00 committed by David S. Miller
parent 6c302e799a
commit 91b6d32563
3 changed files with 4 additions and 4 deletions

View File

@ -292,7 +292,7 @@ EXPORT_PER_CPU_SYMBOL_GPL(tcp_orphan_count);
long sysctl_tcp_mem[3] __read_mostly; long sysctl_tcp_mem[3] __read_mostly;
EXPORT_SYMBOL(sysctl_tcp_mem); EXPORT_SYMBOL(sysctl_tcp_mem);
atomic_long_t tcp_memory_allocated; /* Current allocated memory. */ atomic_long_t tcp_memory_allocated ____cacheline_aligned_in_smp; /* Current allocated memory. */
EXPORT_SYMBOL(tcp_memory_allocated); EXPORT_SYMBOL(tcp_memory_allocated);
#if IS_ENABLED(CONFIG_SMC) #if IS_ENABLED(CONFIG_SMC)
@ -303,7 +303,7 @@ EXPORT_SYMBOL(tcp_have_smc);
/* /*
* Current number of TCP sockets. * Current number of TCP sockets.
*/ */
struct percpu_counter tcp_sockets_allocated; struct percpu_counter tcp_sockets_allocated ____cacheline_aligned_in_smp;
EXPORT_SYMBOL(tcp_sockets_allocated); EXPORT_SYMBOL(tcp_sockets_allocated);
/* /*

View File

@ -122,7 +122,7 @@ EXPORT_SYMBOL(udp_table);
long sysctl_udp_mem[3] __read_mostly; long sysctl_udp_mem[3] __read_mostly;
EXPORT_SYMBOL(sysctl_udp_mem); EXPORT_SYMBOL(sysctl_udp_mem);
atomic_long_t udp_memory_allocated; atomic_long_t udp_memory_allocated ____cacheline_aligned_in_smp;
EXPORT_SYMBOL(udp_memory_allocated); EXPORT_SYMBOL(udp_memory_allocated);
#define MAX_UDP_PORTS 65536 #define MAX_UDP_PORTS 65536

View File

@ -48,7 +48,7 @@ enum {
MPTCP_CMSG_TS = BIT(0), MPTCP_CMSG_TS = BIT(0),
}; };
static struct percpu_counter mptcp_sockets_allocated; static struct percpu_counter mptcp_sockets_allocated ____cacheline_aligned_in_smp;
static void __mptcp_destroy_sock(struct sock *sk); static void __mptcp_destroy_sock(struct sock *sk);
static void __mptcp_check_send_data_fin(struct sock *sk); static void __mptcp_check_send_data_fin(struct sock *sk);