From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org, joannelkoong@gmail.com,
akpm@linux-foundation.org
Cc: David Hildenbrand <david@kernel.org>
Subject: [to-be-updated] mm-add-anonymous-mthp-folios-to-the-deferred-split-list.patch removed from -mm tree
Date: Sat, 07 Nov 2026 17:49:32 -0800 [thread overview]
Message-ID: <20261108014932.D26931F0089F@smtp.kernel.org> (raw)
The quilt patch titled
Subject: mm: add anonymous mTHP folios to the deferred split list
has been removed from the -mm tree. Its filename was
mm-add-anonymous-mthp-folios-to-the-deferred-split-list.patch
This patch was dropped because an updated version will be issued
------------------------------------------------------
From: Joanne Koong <joannelkoong@gmail.com>
Subject: mm: add anonymous mTHP folios to the deferred split list
Date: Tue, 03 Nov 2026 13:20:04 -0800
Unlike for PMD-sized folios, an anonymous mTHP folio doesn't get added
to the deferred split list at fault or collapse time. As a result, a
fully mapped mTHP folio that is mostly zero-filled doesn't get split by
the deferred split shrinker when the system is under memory pressure.
At Meta we would like to deploy 2M THP=always on arm64 with 64k base
pages, as 2M gives the contpte benefits while the PMD size (512M) is too
big to use. Without underused splitting this causes memory regressions,
as the unused parts of those folios can never be broken down and
reclaimed.
Add anonymous mTHP folios to the deferred split list from
map_anon_folio_pte_nopf(), mirroring what map_anon_folio_pmd_nopf()
already does for PMD-sized folios. This covers both the fault path and
the khugepaged mTHP collapse path. If there is memory pressure, a
zero-filled mTHP can then be split with its zero pages remapped to the
shared zero page and reclaimed.
Only queue mTHP folios of at least 2M for underused splitting. With
thp_underused() scaling khugepaged/max_ptes_none to the folio size, any
folio of order 2 or above could in principle be underused, but for small
folios it is unlikely to be worth it. An order-2 folio on 4k base pages
can free at most four pages and on systems that only enable small mTHP
sizes (eg Android's order-2-only configuration) zero-filled subpages
tend to be few and short-lived.
The minimum is hard-coded rather than a knob, since admins have no good
way of choosing it, and is a size rather than an order since what a
split recovers depends on the folio's size in bytes, and the same order
means very different sizes across different base page sizes. It can be
lowered later if data shows smaller sizes are worth it. PMD-sized folios
are exempt from the minimum in order to maintain backwards compatibility
since on some architectures (s390, with a 1M PMD) the PMD size can be
below 2M.
To minimize overhead on the common order-0 fault path, the
deferred_split_folio() call is guarded by an inline folio_test_large()
check.
Link: https://lore.kernel.org/20261103212004.1356327-5-joannelkoong@gmail.com
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Usama Arif <usama.arif@linux.dev>
Reviewed-by: Barry Song <baohua@kernel.org>
Tested-by: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kiryl Shutsemau <kas@kernel.org>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Nico Pache <nico.pache@linux.dev>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/huge_memory.c | 14 ++++++++++++++
mm/memory.c | 2 ++
2 files changed, 16 insertions(+)
--- a/mm/huge_memory.c~mm-add-anonymous-mthp-folios-to-the-deferred-split-list
+++ a/mm/huge_memory.c
@@ -4567,6 +4567,13 @@ static bool thp_underused_never(unsigned
return max_ptes_none == HPAGE_PMD_NR - 1;
}
+/*
+ * Smallest mTHP folio that is queued for underused splitting. Kept
+ * conservative, as small folios are unlikely to free enough memory to be
+ * worth queueing and scanning.
+ */
+#define THP_UNDERUSED_MIN_SIZE SZ_2M
+
/* partially_mapped=false won't clear PG_partially_mapped folio flag */
void deferred_split_folio(struct folio *folio, bool partially_mapped)
{
@@ -4592,6 +4599,13 @@ void deferred_split_folio(struct folio *
*/
if (thp_underused_never(khugepaged_max_ptes_none))
return;
+ /*
+ * Keep queueing PMD-sized folios as before, even where the PMD
+ * size is below the minimum (eg 1M on s390).
+ */
+ if (folio_size(folio) < THP_UNDERUSED_MIN_SIZE &&
+ !is_pmd_order(folio_order(folio)))
+ return;
}
/*
--- a/mm/memory.c~mm-add-anonymous-mthp-folios-to-the-deferred-split-list
+++ a/mm/memory.c
@@ -5472,6 +5472,8 @@ void map_anon_folio_pte_nopf(struct foli
folio_add_lru_vma(folio, vma);
set_ptes(vma->vm_mm, addr, pte, entry, nr_pages);
update_mmu_cache_range(NULL, vma, addr, pte, nr_pages);
+ if (folio_test_large(folio))
+ deferred_split_folio(folio, false);
}
static void map_anon_folio_pte_pf(struct folio *folio, pte_t *pte,
_
Patches currently in -mm which might be from joannelkoong@gmail.com are
memcg-reduce-cacheline-contention-between-lruvec-stat-updates-and-lru-lists.patch
memcg-dont-go-through-the-lruvec-for-folio-and-kmem-lruvec-stat-updates.patch
reply other threads:[~2026-11-08 1:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261108014932.D26931F0089F@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=joannelkoong@gmail.com \
--cc=mm-commits@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.