mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scripts/gdb: support lx-slabinfo on x86
@ 2026-02-01 12:06 Seongjun Hong
  2026-02-01 12:59 ` Jan Kiszka
  0 siblings, 1 reply; 2+ messages in thread
From: Seongjun Hong @ 2026-02-01 12:06 UTC (permalink / raw)
  To: jan.kiszka, kbingham; +Cc: linux-kernel, Seongjun Hong

The lx-slabinfo command failed on x86 because x86_page_ops was not
implemented. This patch implements x86_page_ops in mm.py.

Additionally, CONFIG_PAGE_SHIFT is required for the calculation but
was only available for ARM64 in constants.py.in. This patch moves
it to be available for all architectures.

Signed-off-by: Seongjun Hong <hsj0512@snu.ac.kr>
---
 scripts/gdb/linux/constants.py.in |  2 +-
 scripts/gdb/linux/mm.py           | 25 ++++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/scripts/gdb/linux/constants.py.in b/scripts/gdb/linux/constants.py.in
index c3886739a028..11fd4ba6ba85 100644
--- a/scripts/gdb/linux/constants.py.in
+++ b/scripts/gdb/linux/constants.py.in
@@ -150,8 +150,8 @@ LX_CONFIG(CONFIG_ARM64_64K_PAGES)
 if IS_BUILTIN(CONFIG_ARM64):
     LX_VALUE(CONFIG_ARM64_PA_BITS)
     LX_VALUE(CONFIG_ARM64_VA_BITS)
-    LX_VALUE(CONFIG_PAGE_SHIFT)
     LX_VALUE(CONFIG_ARCH_FORCE_MAX_ORDER)
+LX_VALUE(CONFIG_PAGE_SHIFT)
 LX_CONFIG(CONFIG_SPARSEMEM)
 LX_CONFIG(CONFIG_SPARSEMEM_EXTREME)
 LX_CONFIG(CONFIG_SPARSEMEM_VMEMMAP)
diff --git a/scripts/gdb/linux/mm.py b/scripts/gdb/linux/mm.py
index 7571aebbe650..d6e84e4bf102 100644
--- a/scripts/gdb/linux/mm.py
+++ b/scripts/gdb/linux/mm.py
@@ -26,8 +26,31 @@ class page_ops():
             raise gdb.GdbError('Only support CONFIG_SPARSEMEM_VMEMMAP now')
         if constants.LX_CONFIG_ARM64 and utils.is_target_arch('aarch64'):
             self.ops = aarch64_page_ops()
+        elif utils.is_target_arch('x86_64') or utils.is_target_arch('x86-64'):
+            self.ops = x86_page_ops()
         else:
-            raise gdb.GdbError('Only support aarch64 now')
+            raise gdb.GdbError('Only support aarch64 and x86_64 now')
+
+class x86_page_ops():
+    def __init__(self):
+        self.MAX_NUMNODES = 1 << constants.LX_CONFIG_NODES_SHIFT
+        self.struct_page_size = utils.get_page_type().sizeof
+        self.PAGE_SHIFT = constants.LX_CONFIG_PAGE_SHIFT
+        self.PAGE_SIZE = 1 << self.PAGE_SHIFT
+        self.PAGE_OFFSET = int(gdb.parse_and_eval("page_offset_base"))
+        self.VMEMMAP_START = int(gdb.parse_and_eval("vmemmap_base"))
+
+    def page_to_virt(self, page):
+        page_ptr = page.cast(utils.get_page_type().pointer())
+        vmemmap_ptr = gdb.Value(self.VMEMMAP_START).cast(utils.get_page_type().pointer())
+        idx = int(page_ptr - vmemmap_ptr)
+        return self.PAGE_OFFSET + (idx * self.PAGE_SIZE)
+
+    def page_address(self, page):
+        return self.page_to_virt(page)
+
+    def folio_address(self, folio):
+        return self.page_address(folio['page'].address)
 
 class aarch64_page_ops():
     def __init__(self):
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-01 12:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-01 12:06 [PATCH] scripts/gdb: support lx-slabinfo on x86 Seongjun Hong
2026-02-01 12:59 ` Jan Kiszka

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®