Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ye Liu" <ye.liu@linux.dev>, "Andrew Morton" <akpm@linux-foundation.org>
Cc: "SeongJae Park" <sj@kernel.org>,
	"Stephen Brennan" <stephen.s.brennan@oracle.com>,
	linux-mm@kvack.org, "Ye Liu" <liuye@kylinos.cn>
Subject: Re: [PATCH v2] tools/mm: rewrite show_page_info.py with modular design and new features
Date: Thu, 22 Oct 2026 00:49:29 +0000	[thread overview]
Message-ID: <sashiko-outbox-180837@kernel.org> (raw)
In-Reply-To: <20261021-show_page_info_refactor-v2-1-c28d1173b336@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] tools/mm: _compound_fields() queries compound order on tail page instead of head
--

commit 559aca0f2b19f1194e73dadf4d12451f4bc08a7d
Author: Ye Liu <liuye@kylinos.cn>

tools/mm: rewrite show_page_info.py with modular design and new features

This commit rewrites tools/mm/show_page_info.py into a modular
field-collector design, adds new input modes and page debugging fields, and
fixes field access issues for slab, memcg, and compound pages.

> diff --git a/tools/mm/show_page_info.py b/tools/mm/show_page_info.py
> index c46d8ea283d7d..638fc669b694a 100644
> --- a/tools/mm/show_page_info.py
> +++ b/tools/mm/show_page_info.py

[ ... ]

> +def _compound_fields(page, head, fields):
> +    """Collect compound page fields."""
> +    if not PageCompound(page):
> +        return
> +    fields["Compound Order"] = compound_order(page).value_()
> +    offset = page_to_pfn(page).value_() - page_to_pfn(head).value_()
> +    fields["Folio Page Index"] = f"{offset}/{compound_nr(page).value_()}"
> +    if head.value_() != page.value_():
> +        fields["Head Page"] = hex(head.value_())

[Severity: Medium]
When show_page_state() calls _compound_fields() in
tools/mm/show_page_info.py for a tail page of a compound page, should
compound_order() and compound_nr() be called on head instead of page?

Both the kernel's compound_order() in include/linux/mm.h and drgn's
compound_order() check whether PG_head is set on the page passed to them
and return 0 for tail pages:

include/linux/mm.h:compound_order() {
	const struct folio *folio = (struct folio *)page;

	if (!test_bit(PG_head, &folio->flags.f))
		return 0;
	return folio_large_order(folio);
}

Because compound_nr() computes 1 << compound_order(), passing a tail page
causes _compound_fields() to report Compound Order as 0 and Folio Page
Index as <offset>/1 instead of using the compound head's order and page
count.

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261021-show_page_info_refactor-v2-1-c28d1173b336@linux.dev?part=1


      reply	other threads:[~2026-10-22  0:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21  0:49 [PATCH v2] tools/mm: rewrite show_page_info.py with modular design and new features Ye Liu
2026-10-22  0:49 ` 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-180837@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=liuye@kylinos.cn \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sj@kernel.org \
    --cc=stephen.s.brennan@oracle.com \
    --cc=ye.liu@linux.dev \
    /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