From: Lance Yang Date: Mon, 8 Sep 2025 09:07:41 +0000 (+0800) Subject: mm: skip mlocked THPs that are underused early in deferred_split_scan() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3ba281d1b0f3e2c648e5b208d35492cfb1d4478a;p=users%2Fjedix%2Flinux-maple.git mm: skip mlocked THPs that are underused early in deferred_split_scan() 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. Link: https://lkml.kernel.org/r/20250908090741.61519-1-lance.yang@linux.dev Signed-off-by: Lance Yang Suggested-by: David Hildenbrand Acked-by: David Hildenbrand Acked-by: Usama Arif Reviewed-by: Lorenzo Stoakes Reviewed-by: Baolin Wang Cc: Barry Song Cc: Dev Jain Cc: Lance Yang Cc: Liam Howlett Cc: Mariano Pache Cc: Ryan Roberts Cc: Zi Yan Cc: Kiryl Shutsemau Signed-off-by: Andrew Morton --- diff --git a/mm/huge_memory.c b/mm/huge_memory.c index a9fc7a09167a7..5acca24bbabbe 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -4175,6 +4175,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;