tools/mm: Add script to display page state for a given PID and VADDR
Subsystems (3)
PATCH v2 1/1 tools/mm: Add script to display page state for a given PID and VADDR
From: Ye Liu <[email protected]>
Introduces a new drgn script, show_page_info.py, which allows users to analyze the state of a page given a process ID (PID) and a virtual address (VADDR). This can help kernel developers or debuggers easily inspect page-related information in a live kernel or vmcore.
The script extracts information such as the page flags, mapping, and other metadata relevant to diagnosing memory issues.
Output example:
sudo ./show_page_info.py 1 0x7f2c7de4c000
PID : 1 Comm : systemd mm : 0xffff888116b6d440
User Virtual Address : 0x7f2c7de4c000
Page Address : 0xffffea000b3a4000
raw: 0017ffffc000416c ffffea00045d1b08 ffffea000456d408 ffff888104521970 raw: 0000000000000000 ffff8881083fdb60 0000006900000018 ffff888107a41000
Page Flags : PG_referenced|PG_uptodate|PG_lru|PG_head|PG_active|
PG_private|PG_reported
Page Size : 16384
Page PFN : 0x2ce900
Page Physical : 0x2ce900000
Page Virtual : 0xffff8882ce900000
Page Refcount : 105
Page Mapcount : 24
Page Index : 0x0
Page Memcg Data : 0xffff888107a41000
Memcg Name : init.scope
Memcg Path : /sys/fs/cgroup/memory/init.scope
Page Mapping : 0xffff888104521970
Page Anon/File : File
Page VMA : 0xffff888109e135e8
VMA Start : 0x7f2c7de4c000
VMA End : 0x7f2c7de58000
This page is part of a compound page.
This page is the head page of a compound page.
Head Page : 0xffffea000b3a4000
Compound Order : 2
Number of Pages : 4
Changes in v2:
- Move the show_page_info.py file to tools/mm.
- Link to v1: https://lore.kernel.org/all/[email protected]/
--- MAINTAINERS | 5 ++ tools/mm/show_page_info.py | 114 +++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100755 tools/mm/show_page_info.py
MAINTAINERS +5 -0
@@ -18351,6 +18351,11 @@ F: Documentation/mm/page_table_check.rst F: include/linux/page_table_check.h F: mm/page_table_check.c +PAGE STATE DEBUG SCRIPT +M: Ye Liu <[email protected]> +S: Maintained +F: tools/mm/show_page_info.py + PANASONIC LAPTOP ACPI EXTRAS DRIVER M: Kenneth Chan <[email protected]> L: [email protected]
tools/mm/show_page_info.py new file +114 -0
114 lines not on this page · raw message
Signature · 1 line
2.25.1
Andrew Morton
maintainerQuoted 1 line · On Mon, 21 Apr 2025 16:07:48 +0800 Ye Liu <[email protected]> wrote:
Output example:
The spacing around the colons is inconsistent and a bit odd, IMO.
Quoted 2 lines
sudo ./show_page_info.py 1
0x7f2c7de4c000
PID : 1 Comm : systemd mm :0xffff888116b6d440
PID: 1 Comm: systemd mm: 0xffff888116b6d440
would be more conventional. Or
PID:1 Comm:systemd mm:0xffff888116b6d440
Quoted 18 lines
User Virtual Address :
0x7f2c7de4c000
Page Address :0xffffea000b3a4000raw: 0017ffffc000416c ffffea00045d1b08 ffffea000456d408 ffff888104521970 raw: 0000000000000000 ffff8881083fdb60 0000006900000018 ffff888107a41000Page Flags : PG_referenced|PG_uptodate|PG_lru|PG_head|PG_active|
PG_private|PG_reported
Page Size : 16384
Page PFN :0x2ce900
Page Physical :0x2ce900000
Page Virtual :0xffff8882ce900000
Page Refcount : 105
Page Mapcount : 24
Page Index :0x0
Page Memcg Data :0xffff888107a41000
Memcg Name : init.scope
Memcg Path :/sys/fs/cgroup/memory/init.scope
Page Mapping :0xffff888104521970
Page Anon/File : File
Quoted 8 lines
Page VMA :
0xffff888109e135e8
VMA Start :0x7f2c7de4c000
VMA End :0x7f2c7de58000
This page is part of a compound page.
This page is the head page of a compound page.
Head Page :0xffffea000b3a4000
Compound Order : 2
Number of Pages : 4
I think the style of /proc/meminfo (for example) would be more expected.