net: move sysctl_mem_pcpu_rsv to net_hotdata

sysctl_mem_pcpu_rsv is used in TCP fast path,
move it to net_hodata for better cache locality.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20240429134025.1233626-6-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Eric Dumazet
2024-04-29 13:40:25 +00:00
committed by Jakub Kicinski
parent f3d93817fb
commit c204fef97e
5 changed files with 8 additions and 7 deletions

View File

@@ -3,10 +3,10 @@
#define _PROTO_MEMORY_H
#include <net/sock.h>
#include <net/hotdata.h>
/* 1 MB per cpu, in page units */
#define SK_MEMORY_PCPU_RESERVE (1 << (20 - PAGE_SHIFT))
extern int sysctl_mem_pcpu_rsv;
static inline bool sk_has_memory_pressure(const struct sock *sk)
{
@@ -65,7 +65,7 @@ sk_memory_allocated_add(const struct sock *sk, int val)
val = this_cpu_add_return(*proto->per_cpu_fw_alloc, val);
if (unlikely(val >= READ_ONCE(sysctl_mem_pcpu_rsv)))
if (unlikely(val >= READ_ONCE(net_hotdata.sysctl_mem_pcpu_rsv)))
proto_memory_pcpu_drain(proto);
}
@@ -76,7 +76,7 @@ sk_memory_allocated_sub(const struct sock *sk, int val)
val = this_cpu_sub_return(*proto->per_cpu_fw_alloc, val);
if (unlikely(val <= -READ_ONCE(sysctl_mem_pcpu_rsv)))
if (unlikely(val <= -READ_ONCE(net_hotdata.sysctl_mem_pcpu_rsv)))
proto_memory_pcpu_drain(proto);
}