From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Lance Yang <lance.yang@linux.dev>
Cc: akpm@linux-foundation.org, david@redhat.com,
Liam.Howlett@oracle.com, baohua@kernel.org,
baolin.wang@linux.alibaba.com, dev.jain@arm.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
npache@redhat.com, ryan.roberts@arm.com, usamaarif642@gmail.com,
ziy@nvidia.com
Subject: Re: [PATCH v2 1/1] mm: skip mlocked THPs that are underused early in deferred_split_scan()
Date: Mon, 8 Sep 2025 17:18:18 +0100 [thread overview]
Message-ID: <095395a6-7cc4-46f5-a74b-0c08cff55e23@lucifer.local> (raw)
In-Reply-To: <20250908090741.61519-1-lance.yang@linux.dev>
On Mon, Sep 08, 2025 at 05:07:41PM +0800, Lance Yang wrote:
> From: Lance Yang <lance.yang@linux.dev>
>
> When we stumble over a fully-mapped mlocked THP in the deferred shrinker,
> it does not make sense to try to detect whether it is underused, because
> try_to_map_unused_to_zeropage(), called while splitting the folio, will not
> actually replace any zeroed pages by the shared zeropage.
>
I see it's along this lovely code path: :)
deferred_split_scan()
(thp_underused() returns true)
-> split_folio()
-> split_folio_to_list()
-> split_huge_page_to_list_to_order()
-> __folio_split()
-> remap_page()
-> remove_migration_ptes()
-> remove_migration_pte()
-> try_to_map_unused_to_zeropage()
(oops mlock'd)
> Splitting the folio in that case does not make any sense, so let's not even
> scan to check if the folio is underused.
>
> Suggested-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Lance Yang <lance.yang@linux.dev>
Anyway this does make a lot of sense! So:
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> ---
> v1 -> v2:
> - Update subject and changelog (per David, thanks!)
> - https://lore.kernel.org/linux-mm/20250908040713.42960-1-lance.yang@linux.dev
>
> mm/huge_memory.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 77f0c3417973..6d99893c18e8 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -4183,6 +4183,13 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
> bool underused = false;
>
> if (!folio_test_partially_mapped(folio)) {
> + /*
> + * See try_to_map_unused_to_zeropage(): we cannot
> + * optimize zero-filled pages after splitting an
> + * mlocked folio.
> + */
> + if (folio_test_mlocked(folio))
> + goto next;
> underused = thp_underused(folio);
> if (!underused)
> goto next;
> --
> 2.49.0
>
next prev parent reply other threads:[~2025-09-08 16:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-08 9:07 Lance Yang
2025-09-08 9:12 ` David Hildenbrand
2025-09-08 9:27 ` Lance Yang
2025-09-08 10:38 ` Kiryl Shutsemau
2025-09-08 11:32 ` David Hildenbrand
2025-09-08 11:44 ` Kiryl Shutsemau
2025-09-08 12:04 ` David Hildenbrand
2025-09-08 12:45 ` Kiryl Shutsemau
2025-09-08 13:00 ` Lance Yang
2025-09-08 11:32 ` Lance Yang
2025-09-08 14:28 ` Usama Arif
2025-09-08 16:18 ` Lorenzo Stoakes [this message]
2025-09-09 6:23 ` Baolin Wang
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=095395a6-7cc4-46f5-a74b-0c08cff55e23@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=dev.jain@arm.com \
--cc=lance.yang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=npache@redhat.com \
--cc=ryan.roberts@arm.com \
--cc=usamaarif642@gmail.com \
--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