Re: [PATCH v4] tools/mm: Add script to display page state for a given PID and VADDR

SeongJae Park <[email protected]> Wed, 28 May 2025 16:42:32 -0700
Newsgroups org.kernel.vger.linux-debuggers,org.kernel.vger.linux-kernel,org.kernel.vger.linux-toolchains,org.kvack.linux-mm
Message-ID <[email protected]>
On Wed, 28 May 2025 17:15:43 +0800 Ye Liu <[email protected]> wrote:

> 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 0x7fb3eb1b2000
> PID: 1 Comm: systemd mm: 0xffff8d27279f9cc0
> Raw: 0017ffffc000416c fffff31105a61b08 fffff31105a63608 ffff8d27121326a8
> Raw: 0000000000000000 ffff8d271b9dcc40 0000002500000007 ffff8d2711f12700
> User Virtual Address: 0x7fb3eb1b2000

This is same to what the user passes as the input.  I think this is not really
needed?

> Page Address:         0xfffff31106356a00
> Page Flags:           PG_referenced|PG_uptodate|PG_lru|PG_head|PG_active|
>                       PG_private|PG_reported|PG_has_hwpoisoned
> Page Size:            4096
> Page PFN:             0x18d5a8
> Page Physical:        0x18d5a8000
> Page Virtual:         0xffff8d274d5a8000
> Page Refcount:        37
> Page Mapcount:        7
> Page Index:           0x0
> Page Memcg Data:      0xffff8d2711f12700
> Memcg Name:           init.scope
> Memcg Path:           /sys/fs/cgroup/memory/init.scope

On my setup, above two lines look like below:

    Memcg Name:           unknown
    Memcg Path:           Unexpected error: 'struct kernfs_node' has no member 'parent'

Maybe there are rooms to improve?

> Page Mapping:         0xffff8d27121326a8
> Page Anon/File:       File
> Page VMA:             0xffff8d26cac47600
> VMA Start:            0x7fb3eb1b2000
> VMA End:              0x7fb3eb1b6000
> This page is part of a compound page.
> This page is the head page of a compound page.
> Head Page:            0xfffff31106356a00
> Compound Order:       2
> Number of Pages:      4
> 
> Signed-off-by: Ye Liu <[email protected]>

On my setup, this tool works without obvious or significant errors.

Tested-by: SeongJae Park <[email protected]>


Thanks,
SJ

[...]