From: "Harry Yoo (Oracle)" <harry@kernel.org>
To: Hongfu Li <lihongfu@kylinos.cn>
Cc: hao.ge@linux.dev, akpm@linux-foundation.org,
pasha.tatashin@soleen.com, roman.gushchin@linux.dev,
surenb@google.com, vbabka@kernel.org, willy@infradead.org,
linux-kernel@vger.kernel.org, Hao Li <hao.li@linux.dev>
Subject: Re: [PATCH] tools/cgroup/slabinfo: Fix use of slab.memcg_data
Date: Mon, 20 Apr 2026 18:32:14 +0900 [thread overview]
Message-ID: <aeXynqp8TthD7yC_@hyeyoo> (raw)
In-Reply-To: <20260420090025.3277598-1-lihongfu@kylinos.cn>
On Mon, Apr 20, 2026 at 05:00:25PM +0800, Hongfu Li wrote:
> Hi Hao,
>
> Thanks for your review.
>
> > > +def objexts_flags_mask():
> > > + try:
> > > + return int(prog.constant('__NR_OBJEXTS_FLAGS')) - 1
> > > + except:
> > > + return 0x7
> > > +
> > > +
> > > def find_memcg_ids(css=prog['root_mem_cgroup'].css, prefix=''):
> > > if not list_empty(css.children.address_of_()):
> > > for css in list_for_each_entry('struct cgroup_subsys_state',
> > > @@ -192,23 +199,24 @@ def main():
> > > # look over all slab folios and look for objects belonging
> > > # to the given memory cgroup
> > > for slab in for_each_slab(prog):
> > > - objcg_vec_raw = slab.memcg_data.value_()
> > > - if objcg_vec_raw == 0:
> > > + objext_vec_raw = slab.obj_exts.value_()
> >
> > Here, we should also check whether it equals OBJEXTS_ALLOC_FAIL,
> >
> > which indicates that the allocation of obj_exts has failed, Or have I
> > missed something here?
>
> An obj_ext with the OBJEXTS_ALLOC_FAIL flag may not belong to any cgroup.
> Should we add a check and break this round of polling, or add a comment
> explaining this scenario?
I think it should just skip that slab and continue.
But it's very subtle: obj_exts == OBJEXTS_ALLOC_FAIL (bit 0) means
it failed to allocate the vector, but (obj_exts != OBJEXTS_ALLOC_FAIL)
&& (obj_exts & MEMCG_DATA_OBJEXTS (bit)) means it is a pointer to
slabobj_ext vector.
There is one more thing to consider: it may not be an array of
slabobj_ext as you may expect.
See how slab_obj_ext() works:
https://lore.kernel.org/linux-mm/20260113061845.159790-1-harry.yoo@oracle.com
> Best Regards,
> Hongfu
--
Cheers,
Harry / Hyeonggon
next prev parent reply other threads:[~2026-04-20 9:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 2:07 [PATCH] tools/cgroup/slabinfo: Fix use of slab.memcg_data Hongfu Li
2026-04-20 3:19 ` Hongfu Li
2026-04-20 7:52 ` Hao Ge
2026-04-20 9:00 ` Hongfu Li
2026-04-20 9:32 ` Harry Yoo (Oracle) [this message]
2026-04-20 11:13 ` Hongfu Li
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=aeXynqp8TthD7yC_@hyeyoo \
--to=harry@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=hao.ge@linux.dev \
--cc=hao.li@linux.dev \
--cc=lihongfu@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=pasha.tatashin@soleen.com \
--cc=roman.gushchin@linux.dev \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=willy@infradead.org \
/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