Commit 0defbb0a authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski
Browse files

net: add per_cpu_fw_alloc field to struct proto



Each protocol having a ->memory_allocated pointer gets a corresponding
per-cpu reserve, that following patches will use.

Instead of having reserved bytes per socket,
we want to have per-cpu reserves.

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Reviewed-by: default avatarShakeel Butt <shakeelb@google.com>
Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 100fdd1f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1254,6 +1254,7 @@ struct proto {
	void			(*enter_memory_pressure)(struct sock *sk);
	void			(*leave_memory_pressure)(struct sock *sk);
	atomic_long_t		*memory_allocated;	/* Current allocated memory. */
	int  __percpu		*per_cpu_fw_alloc;
	struct percpu_counter	*sockets_allocated;	/* Current number of sockets. */

	/*
+2 −0
Original line number Diff line number Diff line
@@ -253,6 +253,8 @@ extern long sysctl_tcp_mem[3];
#define TCP_RACK_NO_DUPTHRESH    0x4 /* Do not use DUPACK threshold in RACK */

extern atomic_long_t tcp_memory_allocated;
DECLARE_PER_CPU(int, tcp_memory_per_cpu_fw_alloc);

extern struct percpu_counter tcp_sockets_allocated;
extern unsigned long tcp_memory_pressure;

+1 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ static inline struct udp_hslot *udp_hashslot2(struct udp_table *table,
extern struct proto udp_prot;

extern atomic_long_t udp_memory_allocated;
DECLARE_PER_CPU(int, udp_memory_per_cpu_fw_alloc);

/* sysctl variables for udp */
extern long sysctl_udp_mem[3];
+4 −0
Original line number Diff line number Diff line
@@ -3798,6 +3798,10 @@ int proto_register(struct proto *prot, int alloc_slab)
		pr_err("%s: missing sysctl_mem\n", prot->name);
		return -EINVAL;
	}
	if (prot->memory_allocated && !prot->per_cpu_fw_alloc) {
		pr_err("%s: missing per_cpu_fw_alloc\n", prot->name);
		return -EINVAL;
	}
	if (alloc_slab) {
		prot->slab = kmem_cache_create_usercopy(prot->name,
					prot->obj_size, 0,
+4 −0
Original line number Diff line number Diff line
@@ -149,6 +149,7 @@ static DEFINE_RWLOCK(dn_hash_lock);
static struct hlist_head dn_sk_hash[DN_SK_HASH_SIZE];
static struct hlist_head dn_wild_sk;
static atomic_long_t decnet_memory_allocated;
static DEFINE_PER_CPU(int, decnet_memory_per_cpu_fw_alloc);

static int __dn_setsockopt(struct socket *sock, int level, int optname,
		sockptr_t optval, unsigned int optlen, int flags);
@@ -454,7 +455,10 @@ static struct proto dn_proto = {
	.owner			= THIS_MODULE,
	.enter_memory_pressure	= dn_enter_memory_pressure,
	.memory_pressure	= &dn_memory_pressure,

	.memory_allocated	= &decnet_memory_allocated,
	.per_cpu_fw_alloc	= &decnet_memory_per_cpu_fw_alloc,

	.sysctl_mem		= sysctl_decnet_mem,
	.sysctl_wmem		= sysctl_decnet_wmem,
	.sysctl_rmem		= sysctl_decnet_rmem,
Loading