From: Ye Liu <ye.liu@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Ye Liu <liuye@kylinos.cn>
Subject: [PATCH 1/3] tools/mm: fix memcg info retrieval in show_page_info.py
Date: Wed, 14 Oct 2026 15:04:28 +0800 [thread overview]
Message-ID: <20261014-show_page_info-v1-1-7a68aee0114a@linux.dev> (raw)
In-Reply-To: <20261014-show_page_info-v1-0-7a68aee0114a@linux.dev>
From: Ye Liu <liuye@kylinos.cn>
Fix obj_cgroup type casting and slabobj_ext field name compatibility.
Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
tools/mm/show_page_info.py | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/tools/mm/show_page_info.py b/tools/mm/show_page_info.py
index c46d8ea283d7..9cfb5cac05a3 100644
--- a/tools/mm/show_page_info.py
+++ b/tools/mm/show_page_info.py
@@ -53,17 +53,18 @@ def get_memcg_info(page):
"""Retrieve memory cgroup information for a page."""
try:
MEMCG_DATA_OBJEXTS = prog.constant("MEMCG_DATA_OBJEXTS").value_()
- MEMCG_DATA_KMEM = prog.constant("MEMCG_DATA_KMEM").value_()
mask = prog.constant('__NR_MEMCG_DATA_FLAGS').value_() - 1
memcg_data = page.memcg_data.read_()
if memcg_data & MEMCG_DATA_OBJEXTS:
slabobj_ext = cast("struct slabobj_ext *", memcg_data & ~mask)
- memcg = slabobj_ext.objcg.memcg.value_()
- elif memcg_data & MEMCG_DATA_KMEM:
- objcg = cast("struct obj_cgroup *", memcg_data & ~mask)
- memcg = objcg.memcg.value_()
+ try:
+ objcg = slabobj_ext._objcg
+ except AttributeError:
+ objcg = slabobj_ext.objcg
+ memcg = objcg.memcg
else:
- memcg = cast("struct mem_cgroup *", memcg_data & ~mask)
+ objcg = Object(prog, "struct obj_cgroup *", memcg_data & ~mask)
+ memcg = objcg.memcg
if memcg.value_() == 0:
return "none", "/sys/fs/cgroup/memory/"
--
2.43.0
next prev parent reply other threads:[~2026-10-14 7:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 7:04 [PATCH 0/3] tools/mm: show_page_info.py enhancements and fixes Ye Liu
2026-10-14 7:04 ` Ye Liu [this message]
2026-10-14 7:04 ` [PATCH 2/3] tools/mm: remove Page Index field from show_page_info Ye Liu
2026-10-14 7:04 ` [PATCH 3/3] tools/mm: add VMA flags decoding and name display to show_page_info.py Ye Liu
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=20261014-show_page_info-v1-1-7a68aee0114a@linux.dev \
--to=ye.liu@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liuye@kylinos.cn \
/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
all inboxes | Powered by JetHome®