From: sashiko-bot@kernel.org
To: "Jose A. Perez de Azpillaga" <azpijr@gmail.com>,
"David Hildenbrand" <david@kernel.org>, "Zi Yan" <ziy@nvidia.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Lorenzo Stoakes" <ljs@kernel.org>
Cc: "Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Liam R. Howlett" <liam@infradead.org>,
"Nico Pache" <nico.pache@linux.dev>,
"Ryan Roberts" <ryan.roberts@arm.com>,
"Dev Jain" <dev.jain@arm.com>, "Barry Song" <baohua@kernel.org>,
"Lance Yang" <lance.yang@linux.dev>,
"Usama Arif" <usama.arif@linux.dev>,
"Kiryl Shutsemau" <kas@kernel.org>,
"Rik van Riel" <riel@surriel.com>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Harry Yoo" <harry@kernel.org>, "Jann Horn" <jannh@google.com>,
linux-mm@kvack.org, "Joanne Koong" <joannelkoong@gmail.com>
Subject: Re: [RFC PATCH 2/2] mm/huge_memory: detect partially mapped shared folios without per-page mapcounts
Date: Thu, 12 Nov 2026 11:36:00 +0000 [thread overview]
Message-ID: <sashiko-outbox-211031@kernel.org> (raw)
In-Reply-To: <20261111113535.330078-3-azpijr@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mm/huge_memory: deferred_split_scan() runs PMD
thp_underused() on mTHPs
--
commit 2f9d38ddfb170d3656f9925bef1e82e9b94ecc37
Author: Jose A. Perez de Azpillaga <azpijr@gmail.com>
mm/huge_memory: detect partially mapped shared folios without per-page mapcounts
This commit queues shared anonymous folios onto the deferred split list
without setting PG_partially_mapped when CONFIG_NO_PAGE_MAPCOUNT cannot tell
at unmap time whether all subpages remain mapped, and walks the rmap in
deferred_split_scan() to check them.
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 8c4a69c797edd..f80fa028dd340 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
[ ... ]
> @@ -4744,6 +4811,15 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
> list_lru_unlock_irq(lru);
> rcu_read_unlock();
>
> + if (!folio_test_partially_mapped(folio) &&
> + folio_needs_mapped_check(folio)) {
> + if (!folio_trylock(folio))
> + goto requeue;
> + /* Sets PG_partially_mapped and puts it back on the queue. */
> + if (folio_mapped_shared_partially(folio))
> + deferred_split_folio(folio, true);
> + folio_unlock(folio);
> + }
> if (!folio_test_partially_mapped(folio)) {
> /*
> * See try_to_map_unused_to_zeropage(): we cannot
> @@ -4752,7 +4828,7 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
> */
> if (folio_test_mlocked(folio))
> goto next;
> - underused = thp_underused(folio);
> + underused = split_underused_thp && thp_underused(folio);
> if (!underused)
> goto next;
> }
[Severity: Medium]
Can deferred_split_scan() now call thp_underused() on a sub-PMD mTHP?
Previously, only map_anon_folio_pmd_nopf() queued folios with
partially_mapped == false, so any folio reaching the !folio_test_partially_mapped(folio)
branch was PMD-sized. __folio_remove_rmap() now queues shared anonymous
folios of any order > 1 with partially_mapped == false when a partial unmap in
one process leaves the folio fully mapped in another. When
folio_mapped_shared_partially() returns false for such a sub-PMD mTHP,
execution falls through to thp_underused(folio):
mm/huge_memory.c:thp_underused() {
...
for (i = 0; i < folio_nr_pages(folio); i++) {
if (pages_identical(folio_page(folio, i), ZERO_PAGE(0))) {
if (++num_zero_pages > khugepaged_max_ptes_none)
return true;
} else {
if (++num_filled_pages >= HPAGE_PMD_NR - khugepaged_max_ptes_none)
return false;
}
}
...
}
Because thp_underused() compares against unscaled HPAGE_PMD_NR and
khugepaged_max_ptes_none thresholds, any khugepaged_max_ptes_none below
HPAGE_PMD_NR - 1 causes reclaim to scan subpages with pages_identical() even
when neither threshold can be reached, or to split fully mapped sub-PMD mTHPs
and increment THP_UNDERUSED_SPLIT_PAGE. Checking folio_test_pmd_mappable(folio)
before calling thp_underused(folio) would avoid this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111113535.330078-1-azpijr@gmail.com?part=2
next prev parent reply other threads:[~2026-11-12 11:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 11:31 [RFC PATCH 0/2] mm/huge_memory: find partially mapped shared folios with NO_PAGE_MAPCOUNT Jose A. Perez de Azpillaga
2026-11-11 11:31 ` [RFC PATCH 1/2] mm/huge_memory: check split_underused_thp in the caller of deferred_split_folio() Jose A. Perez de Azpillaga
2026-11-11 11:31 ` [RFC PATCH 2/2] mm/huge_memory: detect partially mapped shared folios without per-page mapcounts Jose A. Perez de Azpillaga
2026-11-12 11:36 ` sashiko-bot [this message]
2026-11-12 12:43 ` Jose A. Perez de Azpillaga
2026-11-12 12:46 ` [RFC PATCH 0/2] mm/huge_memory: find partially mapped shared folios with NO_PAGE_MAPCOUNT David Hildenbrand (Arm)
2026-11-12 13:03 ` Jose A. Perez de Azpillaga
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-211031@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=azpijr@gmail.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=harry@kernel.org \
--cc=jannh@google.com \
--cc=joannelkoong@gmail.com \
--cc=kas@kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=nico.pache@linux.dev \
--cc=riel@surriel.com \
--cc=ryan.roberts@arm.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=ziy@nvidia.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