From: sashiko-bot@kernel.org
To: "Aveline Noir" <jm5905938@gmail.com>,
"Muchun Song" <muchun.song@linux.dev>,
"Oscar Salvador" <osalvador@suse.de>,
"Andrew Morton" <akpm@linux-foundation.org>
Cc: "David Hildenbrand" <david@kernel.org>,
"Joshua Hahn" <joshua.hahnjy@gmail.com>,
"Usama Arif" <usama.arif@linux.dev>,
"Karl Mehltretter" <kmehltretter@gmail.com>,
"Ackerley Tng" <ackerleytng@google.com>,
"Zhao Li" <enderaoelyther@gmail.com>,
"Jinmeng Zhou" <zhoujinmeng@bytedance.com>,
linux-mm@kvack.org, "Liam R. Howlett" <liam@infradead.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Mike Rapoport" <rppt@kernel.org>,
"Michal Hocko" <mhocko@suse.com>,
"Omar Sandoval" <osandov@osandov.com>,
ye.liu@linux.dev
Subject: Re: [PATCH v2] tools/mm: add a drgn script to show HugeTLB reservations
Date: Sun, 06 Dec 2026 05:44:34 +0000 [thread overview]
Message-ID: <sashiko-outbox-252190@kernel.org> (raw)
In-Reply-To: <20261205-hugetlb-resv-drgn-v2-1-a003280b7e1a@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] tools/mm: read_inode() hardcodes d_alias and drops names on
pre-7.0 kernels
- [Low] tools/mm: private_mappings() walks all system VMAs instead of
inode i_mmap
--
commit 358cf49c98b7fc7aab49399c21a5c680e454abed
Author: Aveline Noir <jm5905938@gmail.com>
tools/mm: add a drgn script to show HugeTLB reservations
This commit adds tools/mm/show_hugetlb_resv.py, a drgn script that walks
hugetlbfs superblocks, private owner VMAs, and detached subpools to attribute
HugeTLB reservations per huge page size, with compatibility probing for older
kernels.
> diff --git a/tools/mm/show_hugetlb_resv.py b/tools/mm/show_hugetlb_resv.py
> new file mode 100755
> index 0000000000000..a3ee2dd622563
> --- /dev/null
> +++ b/tools/mm/show_hugetlb_resv.py
> @@ -0,0 +1,461 @@
[ ... ]
> +def read_inode(inode, hpage_size, legacy_map_member):
[ ... ]
> + try:
> + alias = inode.i_dentry.first.read_()
> + if alias:
> + dentry = container_of(alias, "struct dentry", "d_alias")
> + raw = dentry.d_name.name.string_()
> + name = raw.decode("utf-8", "backslashreplace")
> + except Exception:
> + pass
[Severity: Low]
Does this container_of() drop all inode names on kernels older than commit
2420067cecac ("struct dentry: make ->d_u anonymous")?
Before that commit, d_alias was inside the named union d_u, so drgn raises
LookupError for an unqualified "d_alias" lookup and the except block silently
leaves name as None. Probing prog.type("struct dentry").has_member("d_alias")
once and falling back to "d_u.d_alias" would preserve names on older vmcores.
[ ... ]
> +def private_mappings(prog, issues):
> + by_resv_map, vmas_by_hstate = defaultdict(list), defaultdict(list)
> + seen_mms = set()
> + with record_errors(issues, "private tasks"):
> + vm_hugetlb = vma_flag_mask(prog, "VMA_HUGETLB_BIT", 0x00400000)
> + vm_mayshare = vma_flag_mask(prog, "VMA_MAYSHARE_BIT", 0x00000080)
> + base_page_size = int(prog["PAGE_SIZE"])
> + for task in for_each_task(prog):
> + try:
> + mm = task.mm.read_()
> + mm_addr = int(mm)
> + if not mm_addr or mm_addr in seen_mms:
> + continue
> + seen_mms.add(mm_addr)
> + for hstate_addr, vma in list(owner_vmas(task, mm, vm_hugetlb,
> + vm_mayshare,
> + base_page_size)):
> + by_resv_map[vma["resv_map"]].append((hstate_addr, vma))
> + except Exception as err:
> + issues.append(f"task {int(task):#x}: {error_text(err)}")
[Severity: Low]
Can private_mappings() walk inode->i_data.i_mmap on the already-collected
hugetlbfs inodes instead of scanning every VMA of every task?
Every HugeTLB mapping, including private anonymous ones, is backed by a
hugetlbfs inode already found by hugetlbfs_superblocks() and linked into its
i_mmap tree.
Scanning every process's VMA tree scales with total system VMAs, and on a
live kernel any concurrent mmap or exit in an unrelated task can raise an
exception that forces status=incomplete even when HugeTLB state is idle.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-hugetlb-resv-drgn-v2-1-a003280b7e1a@gmail.com?part=1
prev parent reply other threads:[~2026-12-06 5:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 5:33 [PATCH v2] tools/mm: add a drgn script to show HugeTLB reservations Aveline Noir
2026-12-06 5:44 ` sashiko-bot [this message]
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=sashiko-outbox-252190@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ackerleytng@google.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=enderaoelyther@gmail.com \
--cc=jm5905938@gmail.com \
--cc=joshua.hahnjy@gmail.com \
--cc=kmehltretter@gmail.com \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=osandov@osandov.com \
--cc=rppt@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=ye.liu@linux.dev \
--cc=zhoujinmeng@bytedance.com \
/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