From: Eric Dumazet edumazet@google.com
mainline inclusion from mainline-v5.17-rc1 commit 91b6d325635617540b6a1646ddb138bb17cbd569 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I65HYE
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
---------------------------
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 (cherry picked from commit 91b6d325635617540b6a1646ddb138bb17cbd569) Signed-off-by: Liu Jian liujian56@huawei.com
Conflicts: net/mptcp/protocol.c --- net/ipv4/tcp.c | 4 ++-- net/ipv4/udp.c | 2 +- net/mptcp/protocol.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 5d6fa168fb8d4..ca6b15148fecd 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -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);
/* diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index aa526322cfcba..8ab125298b8e9 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -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 diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 72d944e6a641f..402b3da730d41 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -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.