Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sock: Doc behaviors for pressure heurisitics

There are now two accounting infrastructures for skmem, while the
heuristics in __sk_mem_raise_allocated() were actually introduced
before memcg was born.

Add some comments to clarify whether they can be applied to both
infrastructures or not.

Suggested-by: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Abel Wu <wuyun.abel@bytedance.com>
Acked-by: Shakeel Butt <shakeelb@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20231019120026.42215-2-wuyun.abel@bytedance.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Abel Wu and committed by
Paolo Abeni
2e12072c 2def8ff3

+13 -1
+13 -1
net/core/sock.c
··· 3067 3067 if (allocated > sk_prot_mem_limits(sk, 2)) 3068 3068 goto suppress_allocation; 3069 3069 3070 - /* guarantee minimum buffer size under pressure */ 3070 + /* Guarantee minimum buffer size under pressure (either global 3071 + * or memcg) to make sure features described in RFC 7323 (TCP 3072 + * Extensions for High Performance) work properly. 3073 + * 3074 + * This rule does NOT stand when exceeds global or memcg's hard 3075 + * limit, or else a DoS attack can be taken place by spawning 3076 + * lots of sockets whose usage are under minimum buffer size. 3077 + */ 3071 3078 if (kind == SK_MEM_RECV) { 3072 3079 if (atomic_read(&sk->sk_rmem_alloc) < sk_get_rmem0(sk, prot)) 3073 3080 return 1; ··· 3095 3088 3096 3089 if (!sk_under_memory_pressure(sk)) 3097 3090 return 1; 3091 + 3092 + /* Try to be fair among all the sockets under global 3093 + * pressure by allowing the ones that below average 3094 + * usage to raise. 3095 + */ 3098 3096 alloc = sk_sockets_allocated_read_positive(sk); 3099 3097 if (sk_prot_mem_limits(sk, 2) > alloc * 3100 3098 sk_mem_pages(sk->sk_wmem_queued +