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.

memcg: net: track network throttling due to memcg memory pressure

The kernel can throttle network sockets if the memory cgroup associated
with the corresponding socket is under memory pressure. The throttling
actions include clamping the transmit window, failing to expand receive or
send buffers, aggressively prune out-of-order receive queue, FIN deferred
to a retransmitted packet and more. Let's add memcg metric to track such
throttling actions.

At the moment memcg memory pressure is defined through vmpressure and in
future it may be defined using PSI or we may add more flexible way for the
users to define memory pressure, maybe through ebpf. However the
potential throttling actions will remain the same, so this newly
introduced metric will continue to track throttling actions irrespective
of how memcg memory pressure is defined.

Link: https://lkml.kernel.org/r/20251016161035.86161-1-shakeel.butt@linux.dev
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Daniel Sedlak <daniel.sedlak@cdn77.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kacinski <kuba@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Neal Cardwell <ncardwell@google.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Shakeel Butt and committed by
Andrew Morton
d929525c a059ad48

+14 -1
+4
Documentation/admin-guide/cgroup-v2.rst
··· 1515 1515 oom_group_kill 1516 1516 The number of times a group OOM has occurred. 1517 1517 1518 + sock_throttled 1519 + The number of times network sockets associated with 1520 + this cgroup are throttled. 1521 + 1518 1522 memory.events.local 1519 1523 Similar to memory.events but the fields in the file are local 1520 1524 to the cgroup i.e. not hierarchical. The file modified event
+1
include/linux/memcontrol.h
··· 52 52 MEMCG_SWAP_HIGH, 53 53 MEMCG_SWAP_MAX, 54 54 MEMCG_SWAP_FAIL, 55 + MEMCG_SOCK_THROTTLED, 55 56 MEMCG_NR_MEMORY_EVENTS, 56 57 }; 57 58
+5 -1
include/net/sock.h
··· 2635 2635 #endif /* CONFIG_MEMCG_V1 */ 2636 2636 2637 2637 do { 2638 - if (time_before64(get_jiffies_64(), mem_cgroup_get_socket_pressure(memcg))) 2638 + if (time_before64(get_jiffies_64(), 2639 + mem_cgroup_get_socket_pressure(memcg))) { 2640 + memcg_memory_event(mem_cgroup_from_sk(sk), 2641 + MEMCG_SOCK_THROTTLED); 2639 2642 return true; 2643 + } 2640 2644 } while ((memcg = parent_mem_cgroup(memcg))); 2641 2645 2642 2646 return false;
+1
kernel/cgroup/cgroup.c
··· 4704 4704 } 4705 4705 spin_unlock_irqrestore(&cgroup_file_kn_lock, flags); 4706 4706 } 4707 + EXPORT_SYMBOL_GPL(cgroup_file_notify); 4707 4708 4708 4709 /** 4709 4710 * cgroup_file_show - show or hide a hidden cgroup file
+3
mm/memcontrol.c
··· 81 81 EXPORT_SYMBOL(memory_cgrp_subsys); 82 82 83 83 struct mem_cgroup *root_mem_cgroup __read_mostly; 84 + EXPORT_SYMBOL(root_mem_cgroup); 84 85 85 86 /* Active memory cgroup to use from an interrupt context */ 86 87 DEFINE_PER_CPU(struct mem_cgroup *, int_active_memcg); ··· 4464 4463 atomic_long_read(&events[MEMCG_OOM_KILL])); 4465 4464 seq_printf(m, "oom_group_kill %lu\n", 4466 4465 atomic_long_read(&events[MEMCG_OOM_GROUP_KILL])); 4466 + seq_printf(m, "sock_throttled %lu\n", 4467 + atomic_long_read(&events[MEMCG_SOCK_THROTTLED])); 4467 4468 } 4468 4469 4469 4470 static int memory_events_show(struct seq_file *m, void *v)