From: Joanne Koong <joannelkoong@gmail.com>
To: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org
Cc: baohua@kernel.org, usama.arif@linux.dev, hannes@cmpxchg.org,
kas@kernel.org, alex@ghiti.fr, ziy@nvidia.com,
baolin.wang@linux.alibaba.com, liam@infradead.org,
npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com,
lance.yang@linux.dev, vbabka@kernel.org, rppt@kernel.org,
surenb@google.com, mhocko@suse.com, willy@infradead.org,
linux-mm@kvack.org
Subject: [PATCH v3 0/3] mm: split underused anonymous mTHP folios
Date: Fri, 23 Oct 2026 16:00:03 -0700 [thread overview]
Message-ID: <20261023230006.3759543-1-joannelkoong@gmail.com> (raw)
PMD-sized THPs that are mostly zero-filled are reclaimed under memory
pressure by the deferred split shrinker, but this is not done for mTHP
folios. At Meta we would like to deploy 2M THP=always on arm64 with 64k
base pages, as 2M provides the contpte benefits while the PMD size there
(512M) is too big to use. However, 2M THP=always causes memory regressions
unless the unused portions of those folios can be broken down and
reclaimed.
This series lets the underused shrinker handle anonymous mTHP folios. It has
three patches:
Patch 1 makes thp_underused() folio-size-aware. It scales
khugepaged/max_ptes_none to the folio size, so every folio tolerates the same
fraction of zero-filled pages.
Patch 2 stops queueing folios for underused splitting when
khugepaged/max_ptes_none is at its default maximum, where the shrinker
would never split them anyway. This applies to PMD-sized folios too,
which are unconditionally queued today.
Patch 3 queues anonymous mTHP folios on the deferred split list, with a
hard-coded 2M minimum folio size as suggested by Barry. PMD-sized folios are
exempt from the minimum, since on s390 the PMD size is 1M.
At the default khugepaged/max_ptes_none, no folio is queued for underused
splitting. Once it's lowered, mTHP folios of at least 2M are queued along with
PMD-sized folios.
Changelog
---------
v2: https://lore.kernel.org/linux-mm/20260916224437.1164512-1-joannelkoong@gmail.com/
Changes since v2:
* Go back to scaling khugepaged/max_ptes_none per folio size (David)
* Keep the check for the sysctl maximum on the raw, unscaled value
(Sashiko, from v1). Round the scaled value up so a folio is never
split when fewer than the configured fraction of its pages are
zero-filled.
* Only queue mTHP folios of at least 2M, a hard-coded minimum (Barry, David)
v1: https://lore.kernel.org/linux-mm/20260707201735.4113107-1-joannelkoong@gmail.com/
Changes since v1:
* Drop the per-order scaling of khugepaged_max_ptes_none. Keep it
absolute, matching collapse (David, Johannes)
* New patch 2 (suggested by Johannes): don't queue folios that can never
be underused, which both bounds what patch 3 adds and stops queuing PMD
folios under default settings (Johannes, David, Barry)
* Fix the thp_underused() early exit to scale to the folio's own size
Joanne Koong (3):
mm/huge_memory: scale thp_underused() to the folio size
mm/huge_memory: don't queue folios when underused splitting is
inactive
mm: add anonymous mTHP folios to the deferred split list
mm/huge_memory.c | 58 +++++++++++++++++++++++++++++++++++++++++-------
mm/memory.c | 2 ++
2 files changed, 52 insertions(+), 8 deletions(-)
base-commit: 3fdcce698abd9193752ee89fb1a440cdceb1b74a
--
2.52.0
next reply other threads:[~2026-10-23 23:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 23:00 Joanne Koong [this message]
2026-10-23 23:00 ` [PATCH v3 1/3] mm/huge_memory: scale thp_underused() to the folio size Joanne Koong
2026-10-24 23:01 ` sashiko-bot
2026-10-27 2:00 ` Lance Yang
2026-10-23 23:00 ` [PATCH v3 2/3] mm/huge_memory: don't queue folios when underused splitting is inactive Joanne Koong
2026-10-27 18:05 ` Kiryl Shutsemau
2026-10-23 23:00 ` [PATCH v3 3/3] mm: add anonymous mTHP folios to the deferred split list Joanne Koong
2026-10-27 18:22 ` Kiryl Shutsemau
2026-10-27 23:20 ` Joanne Koong
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=20261023230006.3759543-1-joannelkoong@gmail.com \
--to=joannelkoong@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=hannes@cmpxchg.org \
--cc=kas@kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=npache@redhat.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=surenb@google.com \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=willy@infradead.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