Skip to content

Commit 933804e

Browse files
Tengteng YangNipaLocal
Tengteng Yang
authored and
NipaLocal
committed
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 2def8ff ("sock: Code cleanup on __sk_mem_raise_allocated()"). The fix changes the default value of charged to true while preserving existing logic. Fixes: 2def8ff ("sock: Code cleanup on __sk_mem_raise_allocated()") Signed-off-by: Abel Wu <[email protected]> Signed-off-by: Tengteng Yang <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 10dbf60 commit 933804e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/core/sock.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3274,16 +3274,16 @@ int __sk_mem_raise_allocated(struct sock *sk, int size, int amt, int kind)
32743274
{
32753275
struct mem_cgroup *memcg = mem_cgroup_sockets_enabled ? sk->sk_memcg : NULL;
32763276
struct proto *prot = sk->sk_prot;
3277-
bool charged = false;
3277+
bool charged = true;
32783278
long allocated;
32793279

32803280
sk_memory_allocated_add(sk, amt);
32813281
allocated = sk_memory_allocated(sk);
32823282

32833283
if (memcg) {
3284-
if (!mem_cgroup_charge_skmem(memcg, amt, gfp_memcg_charge()))
3284+
charged = mem_cgroup_charge_skmem(memcg, amt, gfp_memcg_charge());
3285+
if (!charged)
32853286
goto suppress_allocation;
3286-
charged = true;
32873287
}
32883288

32893289
/* Under limit. */
@@ -3368,7 +3368,7 @@ int __sk_mem_raise_allocated(struct sock *sk, int size, int amt, int kind)
33683368

33693369
sk_memory_allocated_sub(sk, amt);
33703370

3371-
if (charged)
3371+
if (memcg && charged)
33723372
mem_cgroup_uncharge_skmem(memcg, amt);
33733373

33743374
return 0;

0 commit comments

Comments
 (0)