From: Matyas Hurtik <matyas.hurtik@cdn77.com>
To: "Tejun Heo" <tj@kernel.org>, "Michal Koutný" <mkoutny@suse.com>
Cc: Daniel Sedlak <daniel.sedlak@cdn77.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
Neal Cardwell <ncardwell@google.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
David Ahern <dsahern@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Shakeel Butt <shakeel.butt@linux.dev>,
Yosry Ahmed <yosry.ahmed@linux.dev>,
linux-mm@kvack.org, netdev@vger.kernel.org,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Muchun Song <muchun.song@linux.dev>,
cgroups@vger.kernel.org
Subject: Re: [PATCH v4] memcg: expose socket memory pressure in a cgroup
Date: Wed, 20 Aug 2025 18:51:07 +0200 [thread overview]
Message-ID: <e65222c1-83f9-4d23-b9af-16db7e6e8a42@cdn77.com> (raw)
In-Reply-To: <aJzTeyRTu_sfm-9R@slm.duckdns.org>
Hello,
On 8/13/25 8:03 PM, Tejun Heo wrote:
> On Wed, Aug 13, 2025 at 02:03:28PM +0200, Michal Koutný wrote:
> ...
>> One more point to clarify -- should the value include throttling from
>> ancestors or not. (I think both are fine but) this semantic should also
>> be described in the docs. I.e. current proposal is
>> value = sum_children + self
>> and if you're see that C's value is 0, it doesn't mean its sockets
>> weren't subject of throttling. It just means you need to check also
>> values in C ancestors. Does that work?
> I was more thinking that it would account for all throttled durations, but
> it's true that we only count locally originating events for e.g.
> memory.events::low or pids.events::max. Hmm... I'm unsure. So, for events, I
> think local sources make sense as it's tracking what limits are triggering
> where. However, I'm not sure that translates well to throttle duration which
> is closer to pressure metrics than event counters. We don't distinguish the
> sources of contention when presenting pressure metrics after all.
I think calculating the value using self and ancestors would better match
the logic in mem_cgroup_under_socket_pressure() and it would avoid the
issue Michal outlined without relying on an explanation in the docs -
checking a single value per cgroup to confirm whether sockets belonging
to that cgroup were being throttled looks more intuitive to me.
If we were to have the write side of the stat in vmpressure() look
something like:
new_socket_pressure = jiffies + HZ;
old_socket_pressure = atomic_long_xchg(
&memcg->socket_pressure, new_socket_pressure);
duration_to_add = jiffies_to_usecs(
min(new_socket_pressure - old_socket_pressure, HZ));
atomic_long_add(duration_to_add, &memcg->socket_pressure_duration);
And the read side:
total_duration = 0;
for (; !mem_cgroup_is_root(memcg); memcg = parent_mem_cgroup(memcg))
total_duration += atomic_long_read(&memcg->socket_pressure_duration);
Would that work?
There would be an issue with the reported value possibly being larger
than the real duration of the throttling, due to overlapping
intervals of socket_pressure with some ancestor. Is that a problem?
Thanks,
Matyas
next prev parent reply other threads:[~2025-08-20 16:51 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 6:44 [PATCH v4] memcg: expose socket memory pressure in a cgroup Daniel Sedlak
2025-08-05 15:54 ` Kuniyuki Iwashima
2025-08-05 23:02 ` Shakeel Butt
2025-08-06 19:20 ` Kuniyuki Iwashima
2025-08-06 21:54 ` Shakeel Butt
2025-08-06 22:01 ` Kuniyuki Iwashima
2025-08-06 23:34 ` Shakeel Butt
2025-08-06 23:40 ` Kuniyuki Iwashima
2025-08-06 23:51 ` Shakeel Butt
2025-08-07 10:22 ` Daniel Sedlak
2025-08-07 20:52 ` Shakeel Butt
2025-08-14 16:27 ` Matyas Hurtik
2025-08-14 17:31 ` Shakeel Butt
2025-08-14 17:43 ` Shakeel Butt
2025-08-07 10:42 ` Daniel Sedlak
2025-08-09 18:32 ` Tejun Heo
2025-08-11 21:31 ` Shakeel Butt
2025-08-13 12:03 ` Michal Koutný
2025-08-13 18:03 ` Tejun Heo
2025-08-20 16:51 ` Matyas Hurtik [this message]
2025-08-20 19:03 ` Tejun Heo
2025-08-20 19:31 ` Shakeel Butt
2025-08-20 20:37 ` Matyas Hurtik
2025-08-20 21:34 ` Shakeel Butt
2025-08-21 18:44 ` Matyas Hurtik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e65222c1-83f9-4d23-b9af-16db7e6e8a42@cdn77.com \
--to=matyas.hurtik@cdn77.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=daniel.sedlak@cdn77.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=hannes@cmpxchg.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=muchun.song@linux.dev \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=tj@kernel.org \
--cc=yosry.ahmed@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).