Re: [PATCH] tools/mm: add a drgn script to show HugeTLB reservations

From: Muchun Song

Date: Fri Nov 27 2026 - 06:30:31 EST




> On Nov 26, 2026, at 19:21, Aveline Noir <jm5905938@xxxxxxxxx> wrote:
>
> Add a drgn script, show_hugetlb_resv.py, to show where HugeTLB
> reservations are held in a live kernel or vmcore.
>
> HugePages_Rsvd in /proc/meminfo only reports the global reservation
> count for the default huge page size. It cannot show which files,
> private mappings or hugetlbfs mounts hold those reservations, or whether
> a subpool is below its minimum.
>
> The script walks those objects per huge page size, compares their
> reservations with resv_huge_pages, and checks subpool minima separately.
> It reads internal hugetlb and hugetlbfs structures, so keeping it in
> tools/mm/ lets it be updated alongside them.
>
> Usage:
>
> drgn -c vmcore -s vmlinux tools/mm/show_hugetlb_resv.py [--json]
> drgn -k tools/mm/show_hugetlb_resv.py [--json]
>
> Output from a vmcore taken before commit e4949a80f3b0 ("mm/hugetlb: fix
> subpool minimum reservation rollback"). All three reserved pages are
> attributed, but the mount is one page below its four-page minimum:
>
> source=dump status=mismatch (counts in huge pages)
>
> 2048 KiB: nr_huge_pages=4 free_huge_pages=4 resv_huge_pages=3
> inode_resv=3 private_resv=0 mounted_resv=0
> attributed=3 unattributed=+0 resv_floor=4 floor_shortfall=1
> sb=0xff11000004000000 path='/huge' min_hpages=4 rsv_hpages=0
> min_shortfall=1 used_hpages=3
> ino=191 name='a' resv_map_pages=3 instantiated=0 outstanding=3
>
> With the fix applied, the same test leaves rsv_hpages=1 and no
> min_shortfall.
>
> Signed-off-by: Aveline Noir <jm5905938@xxxxxxxxx>
> ---
> I wasn't sure where a script like this belongs, so I followed
> tools/mm/show_page_info.py for the placement and MAINTAINERS entry.
> Any feedback is welcome :)

The Dragon project itself probably belongs to this type of script? See
here:

https://github.com/osandov/drgn/tree/main/scripts

Thanks,
Muchun