]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: make SK_MEMORY_PCPU_RESERV tunable
authorAdam Li <adamli@os.amperecomputing.com>
Mon, 26 Feb 2024 02:24:52 +0000 (02:24 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 May 2024 14:32:36 +0000 (16:32 +0200)
commitfe1e83811c4f3eba1f202572a89e968d9d2a433d
treee654efd5dffed93023d21e3876ab58caaf593fa6
parent6a65f015ee4850f588b1afe9e82569a736a4e696
net: make SK_MEMORY_PCPU_RESERV tunable

[ Upstream commit 12a686c2e761f1f1f6e6e2117a9ab9c6de2ac8a7 ]

This patch adds /proc/sys/net/core/mem_pcpu_rsv sysctl file,
to make SK_MEMORY_PCPU_RESERV tunable.

Commit 3cd3399dd7a8 ("net: implement per-cpu reserves for
memory_allocated") introduced per-cpu forward alloc cache:

"Implement a per-cpu cache of +1/-1 MB, to reduce number
of changes to sk->sk_prot->memory_allocated, which
would otherwise be cause of false sharing."

sk_prot->memory_allocated points to global atomic variable:
atomic_long_t tcp_memory_allocated ____cacheline_aligned_in_smp;

If increasing the per-cpu cache size from 1MB to e.g. 16MB,
changes to sk->sk_prot->memory_allocated can be further reduced.
Performance may be improved on system with many cores.

Signed-off-by: Adam Li <adamli@os.amperecomputing.com>
Reviewed-by: Christoph Lameter (Ampere) <cl@linux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stable-dep-of: 3584718cf2ec ("net: fix sk_memory_allocated_{add|sub} vs softirqs")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Documentation/admin-guide/sysctl/net.rst
include/net/sock.h
net/core/sock.c
net/core/sysctl_net_core.c