[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250908090741.61519-1-lance.yang@linux.dev>
Date: Mon, 8 Sep 2025 17:07:41 +0800
From: Lance Yang <lance.yang@...ux.dev>
To: akpm@...ux-foundation.org,
david@...hat.com
Cc: Liam.Howlett@...cle.com,
baohua@...nel.org,
baolin.wang@...ux.alibaba.com,
dev.jain@....com,
linux-kernel@...r.kernel.org,
linux-mm@...ck.org,
lorenzo.stoakes@...cle.com,
npache@...hat.com,
ryan.roberts@....com,
usamaarif642@...il.com,
ziy@...dia.com,
Lance Yang <lance.yang@...ux.dev>
Subject: [PATCH v2 1/1] mm: skip mlocked THPs that are underused early in deferred_split_scan()
From: Lance Yang <lance.yang@...ux.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.
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@...hat.com>
Signed-off-by: Lance Yang <lance.yang@...ux.dev>
---
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
Powered by blists - more mailing lists