[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b4418948-61ce-4cf1-a3d2-a4208e73d5b3@gmail.com>
Date: Thu, 16 Oct 2025 13:28:15 -0700
From: JP Kobryn <inwardvessel@...il.com>
To: Song Liu <song@...nel.org>
Cc: shakeel.butt@...ux.dev, andrii@...nel.org, ast@...nel.org,
mkoutny@...e.com, yosryahmed@...gle.com, hannes@...xchg.org, tj@...nel.org,
akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
cgroups@...r.kernel.org, linux-mm@...ck.org, bpf@...r.kernel.org,
kernel-team@...a.com
Subject: Re: [PATCH v2 1/2] memcg: introduce kfuncs for fetching memcg stats
On 10/15/25 4:12 PM, Song Liu wrote:
> On Wed, Oct 15, 2025 at 12:08 PM JP Kobryn <inwardvessel@...il.com> wrote:
>>
> [...]
>> ---
>> mm/memcontrol.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 67 insertions(+)
>>
>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>> index 4deda33625f4..6547c27d4430 100644
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@ -871,6 +871,73 @@ unsigned long memcg_events_local(struct mem_cgroup *memcg, int event)
>> }
>> #endif
>>
>> +static inline struct mem_cgroup *memcg_from_cgroup(struct cgroup *cgrp)
>> +{
>> + return cgrp ? mem_cgroup_from_css(cgrp->subsys[memory_cgrp_id]) : NULL;
>> +}
>> +
>
> We should add __bpf_kfunc_start_defs() here, and __bpf_kfunc_end_defs()
> after all the kfuncs.
Good call.
>
>> +__bpf_kfunc static void memcg_flush_stats(struct cgroup *cgrp)
>
> We mostly do not make kfunc static, but it seems to also work.
>
>> +{
>> + struct mem_cgroup *memcg = memcg_from_cgroup(cgrp);
>> +
>> + if (!memcg)
>> + return;
>
> Maybe we can let memcg_flush_stats return int, and return -EINVAL
> on memcg == NULL cases?
Sure, I'll do that in v3.
>
>> +
>> + mem_cgroup_flush_stats(memcg);
>> +}
>> +
> [...]
Powered by blists - more mailing lists