From: "Harry Yoo (Oracle)" <harry@kernel.org>
To: Hongfu Li <lihongfu@kylinos.cn>
Cc: willy@infradead.org, Vlastimil Babka <vbabka@kernel.org>,
roman.gushchin@linux.dev, akpm@linux-foundation.org,
pasha.tatashin@soleen.com, surenb@google.com, hao.ge@linux.dev,
linux-kernel@vger.kernel.org, Hao Li <hao.li@linux.dev>
Subject: Re: [PATCH v2] tools/cgroup/slabinfo: Fix use of slab.memcg_data
Date: Tue, 21 Apr 2026 19:42:19 +0900 [thread overview]
Message-ID: <aedUixf6PC0UceaO@hyeyoo> (raw)
In-Reply-To: <20260421055829.3930289-1-lihongfu@kylinos.cn>
On Tue, Apr 21, 2026 at 01:58:29PM +0800, Hongfu Li wrote:
> After the introduce slabobj_ext to support slab object extensions, the
> memcg_slabinfo tool broke. An attempt to run it produces a trace like
> this:
> Traceback (most recent call last):
> File "/usr/local/bin/drgn", line 8, in <module>
> sys.exit(_main())
> ^^^^^^^
> File "/usr/local/lib64/python3.11/site-packages/drgn/cli.py", line 688, in _main
> runpy.run_path(
> File "<frozen runpy>", line 291, in run_path
> File "<frozen runpy>", line 98, in _run_module_code
> File "<frozen runpy>", line 88, in _run_code
> File "/root/memcg_slabinfo.py", line 225, in <module>
> main()
> File "/root/memcg_slabinfo.py", line 195, in main
> objcg_vec_raw = slab.memcg_data.value_()
> AttributeError: 'struct slab' has no member 'memcg_data'
>
> Fixes: 21c690a349ba ("mm: introduce slabobj_ext to support slab object extensions")
> Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
>
> Changes in v2:
Changes between versions should not be part of the commit message.
to the changelog.
> - Skip slabs after masking when the base is zero (OBJEXTS_ALLOC_FAIL).
> - Walk slab->obj_exts using base + stride * i (same indexing as slab_obj_ext()).
These two changes looks good to me.
> - Link to v1: https://lore.kernel.org/all/20260417020729.952897-1-lihongfu@kylinos.cn/
> ---
"Changes since ..." should be under this '---' line so that it won't be
included in the commit message.
Not sure what kernel version you're using, but due to recent changes
in slab (v7.1-rc1), we need this:
diff --git a/tools/cgroup/memcg_slabinfo.py b/tools/cgroup/memcg_slabinfo.py
old mode 100644
new mode 100755
index b5d4e51671cd..e54e2bb65fe2
--- a/tools/cgroup/memcg_slabinfo.py
+++ b/tools/cgroup/memcg_slabinfo.py
@@ -101,7 +101,7 @@ def slub_get_slabinfo(s, cfg):
nr_free = 0
for node in range(cfg['nr_nodes']):
- n = s.node[node]
+ n = s.per_node[node].node
nr_slabs += n.nr_slabs.counter.value_()
nr_objs += n.total_objects.counter.value_()
nr_free += count_partial(n, count_free)
Perhaps you could make it work for kernel w/ and w/o the recent slab
changes. (By checking if the field exists and falling back)
Please address this and adjust the commit message accordingly.
--
Cheers,
Harry / Hyeonggon
prev parent reply other threads:[~2026-04-21 10:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 5:58 [PATCH v2] tools/cgroup/slabinfo: Fix use of slab.memcg_data Hongfu Li
2026-04-21 10:42 ` Harry Yoo (Oracle) [this message]
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=aedUixf6PC0UceaO@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