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.

Fix sock_exceed_buf_limit not being triggered in __sk_mem_raise_allocated

When a process under memory pressure is not part of any cgroup and
the charged flag is false, trace_sock_exceed_buf_limit was not called
as expected.

This regression was introduced by commit 2def8ff3fdb6 ("sock:
Code cleanup on __sk_mem_raise_allocated()"). The fix changes the
default value of charged to true while preserving existing logic.

Fixes: 2def8ff3fdb6 ("sock: Code cleanup on __sk_mem_raise_allocated()")
Signed-off-by: Abel Wu <wuyun.abel@bytedance.com>
Signed-off-by: Tengteng Yang <yangtengteng@bytedance.com>
Link: https://patch.msgid.link/20250527030419.67693-1-yangtengteng@bytedance.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Tengteng Yang and committed by
Jakub Kicinski
8542d6fa 90b83efa

+4 -4
+4 -4
net/core/sock.c
··· 3284 3284 { 3285 3285 struct mem_cgroup *memcg = mem_cgroup_sockets_enabled ? sk->sk_memcg : NULL; 3286 3286 struct proto *prot = sk->sk_prot; 3287 - bool charged = false; 3287 + bool charged = true; 3288 3288 long allocated; 3289 3289 3290 3290 sk_memory_allocated_add(sk, amt); 3291 3291 allocated = sk_memory_allocated(sk); 3292 3292 3293 3293 if (memcg) { 3294 - if (!mem_cgroup_charge_skmem(memcg, amt, gfp_memcg_charge())) 3294 + charged = mem_cgroup_charge_skmem(memcg, amt, gfp_memcg_charge()); 3295 + if (!charged) 3295 3296 goto suppress_allocation; 3296 - charged = true; 3297 3297 } 3298 3298 3299 3299 /* Under limit. */ ··· 3378 3378 3379 3379 sk_memory_allocated_sub(sk, amt); 3380 3380 3381 - if (charged) 3381 + if (memcg && charged) 3382 3382 mem_cgroup_uncharge_skmem(memcg, amt); 3383 3383 3384 3384 return 0;