Re: [PATCH v5] memcg: expose socket memory pressure in a cgroup
From: Roman Gushchin <roman.gushchin@linux.dev>
Date: 2025-10-09 15:32:42
Also in:
cgroups, linux-mm
Daniel Sedlak [off-list ref] writes:
Hi Roman, On 10/8/25 8:58 PM, Roman Gushchin wrote:quoted
quoted
This patch exposes a new file for each cgroup in sysfs which is a read-only single value file showing how many microseconds this cgroup contributed to throttling the throughput of network sockets. The file is accessible in the following path. /sys/fs/cgroup/**/<cgroup name>/memory.net.throttled_usecHi Daniel! How this value is going to be used? In other words, do you need an exact number or something like memory.events::net_throttled would be enough for your case?Just incrementing a counter each time the vmpressure() happens IMO provides bad semantics of what is actually happening, because it can hide important details, mainly the _time_ for how long the network traffic was slowed down. For example, when memory.events::net_throttled=1000, it can mean that the network was slowed down for 1 second or 1000 seconds or something between, and the memory.net.throttled_usec proposed by this patch disambiguates it. In addition, v1/v2 of this series started that way, then from v3 we rewrote it to calculate the duration instead, which proved to be better information for debugging, as it is easier to understand implications.
But how are you planning to use this information? Is this just "networking is under pressure for non-trivial amount of time -> raise the memcg limit" or something more complicated? I am bit concerned about making this metric the part of cgroup API simple because it's too implementation-defined and in my opinion lack the fundamental meaning. Vmpressure is calculated based on scanned/reclaimed ratio (which is also not always the best proxy for the memory pressure level), then if it reaches some level we basically throttle networking for 1s. So it's all very arbitrary. I totally get it from the debugging perspective, but not sure about usefulness of it as a permanent metric. This is why I'm asking if there are lighter alternatives, e.g. memory.events or maybe even tracepoints. Thanks!