Commit d5a5cb7d authored by Eric Dumazet's avatar Eric Dumazet Committed by Liu Jian
Browse files

net: cache align tcp_memory_allocated, tcp_sockets_allocated

mainline inclusion
from mainline-v5.17-rc1
commit 91b6d325
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I65HYE

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=91b6d325635617540b6a1646ddb138bb17cbd569



---------------------------

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: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
(cherry picked from commit 91b6d325)
Signed-off-by: default avatarLiu Jian <liujian56@huawei.com>

Conflicts:
	net/mptcp/protocol.c
parent 42d7d2ee
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -286,7 +286,7 @@ EXPORT_PER_CPU_SYMBOL_GPL(tcp_orphan_count);
long sysctl_tcp_mem[3] __read_mostly;
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);

#if IS_ENABLED(CONFIG_SMC)
@@ -301,7 +301,7 @@ DEFINE_STATIC_KEY_FALSE(tcp_have_comp);
/*
 * 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);

/*
+1 −1
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ EXPORT_SYMBOL(udp_table);
long sysctl_udp_mem[3] __read_mostly;
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);

#define MAX_UDP_PORTS 65536
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ struct mptcp_skb_cb {

#define MPTCP_SKB_CB(__skb)	((struct mptcp_skb_cb *)&((__skb)->cb[0]))

static struct percpu_counter mptcp_sockets_allocated;
static struct percpu_counter mptcp_sockets_allocated ____cacheline_aligned_in_smp;

/* If msk has an initial subflow socket, and the MP_CAPABLE handshake has not
 * completed yet or has failed, return the subflow socket.