From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Nico Pache <npache@redhat.com>
Cc: Usama Arif <usama.arif@linux.dev>, Zi Yan <ziy@nvidia.com>,
ljs@kernel.org, xu.xin16@zte.com.cn,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
usamaarif642@gmail.com, yuzhao@google.com, aarcange@redhat.com,
akpm@linux-foundation.org, chengming.zhou@linux.dev,
baolin.wang@linux.alibaba.com, liam@infradead.org,
ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org,
lance.yang@linux.dev, matthew.brost@intel.com,
joshua.hahnjy@gmail.com, rakie.kim@sk.com, byungchul@sk.com,
gourry@gourry.net, ying.huang@linux.alibaba.com,
apopple@nvidia.com
Subject: Re: [PATCH mm-unstable v1 2/3] mm/migrate.c: Prevent folio splitting from interacting with KSM
Date: Tue, 15 Sep 2026 21:52:30 +0200 [thread overview]
Message-ID: <16f9ea47-99c0-4483-a12f-190047c1411f@kernel.org> (raw)
In-Reply-To: <1da189ad-a7f6-42fa-a1ff-a26cc5e5c563@kernel.org>
On 8/25/26 19:34, David Hildenbrand (Arm) wrote:
> On 8/5/26 18:27, Nico Pache wrote:
>> On Thu, Jul 30, 2026 at 2:34 AM David Hildenbrand (Arm)
>> <david@kernel.org> wrote:
>>>
>>>
>>> Because KSM takes care of it?
>>
>> KSM only takes care of it in the case of 'use_zero_pages' being set.
>> If we stop KSM splits from reclaiming, we regain the intended sysctl
>> behavior; otherwise, KSM splits and reclaims indiscriminately. The
>> secondary effect is that if we don't have this toggle set, the split
>> would still reclaim these pages. KSM then has to process those pages
>> (despite them already being freed), wasting cycles.
>>
>> Your proposed solution works too, I just think its a more aggressive
>> approach (stop all VM_MERGEABLEs from split-reclaiming, not just those
>> that are currently being operated on by KSM).
>
> I think we should really just stop two mechanisms to compete entirely: if A is
> active for a region, B is disabled.
>
> Not trying to follow "who split what" and operate based on that.
>
I took another look and there is just no perfect solution.
Option A: don't let mechanisms interfere - if KSM is enabled, don't remap to the
shared zeropage
Positive: same KSM behavior even if some other mechanism decides to split.
Negative: reclaim cannot free up these pages immediately (waits for KSM), and
having the deferred shrinker split to then not reclaim any actual
memory is stupid.
Given that the second KSM run would already deduplicate these pages, I am not
sure how much reclaim actually matters.
But taming the deferred shrinker is a bit complicated (no VMA available). In
configurations where the deferred shrinker will never trigger a split that's not
a problem, but with lower max_ptes_none it would be possible to trigger.
Option B: don't let KSM splits remap to the shared zeropage
Positive: Fix isolated to the actual problematic part we observed.
Negative: Different KSM behavior depending on who split a THP first.
Assume KSM scanned the range first, and then the deferred shrinker split many
THP in that area and creates shared zeropage. On the next KSM run, we'd have a
very similar behavior. If KSM runs first, you either get zeropages or
deduplication to a zero-filled page.
I would not go down a path where we would let KSM skip THPs entirely.
Maybe one could teach KSM about "the deferred shrinker is active, don't split a
THP if we are to deduplciate the shared zeropage"? But then, whether the
deferred shrinker will actually split depends on the max_ptes_non toggle.
Gahhh so complicated.
--
Cheers,
David
next prev parent reply other threads:[~2026-09-15 19:52 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 11:46 [PATCH mm-unstable v1 0/3] MM: Tighten control over zero-page remapping Nico Pache
2026-06-09 11:46 ` [PATCH mm-unstable v1 1/3] mm/ksm: export ksm_is_running() to check KSM merge state Nico Pache
2026-06-09 14:13 ` Lorenzo Stoakes
2026-06-09 11:46 ` [PATCH mm-unstable v1 2/3] mm/migrate.c: Prevent folio splitting from interacting with KSM Nico Pache
2026-06-09 12:12 ` xu.xin16
2026-06-09 12:57 ` Nico Pache
2026-06-09 12:59 ` David Hildenbrand (Arm)
2026-06-09 13:47 ` xu.xin16
2026-06-09 14:07 ` Zi Yan
2026-06-09 17:27 ` Usama Arif
2026-07-15 4:05 ` Nico Pache
2026-07-15 8:47 ` xu.xin16
2026-07-15 8:56 ` xu.xin16
2026-07-15 9:34 ` David Hildenbrand (Arm)
2026-07-15 9:30 ` David Hildenbrand (Arm)
2026-07-20 15:28 ` Nico Pache
2026-07-21 14:02 ` David Hildenbrand (Arm)
2026-07-29 16:54 ` Nico Pache
2026-07-30 8:33 ` David Hildenbrand (Arm)
2026-08-05 16:27 ` Nico Pache
2026-08-25 17:34 ` David Hildenbrand (Arm)
2026-09-15 19:52 ` David Hildenbrand (Arm) [this message]
2026-07-15 10:54 ` Usama Arif
2026-06-09 13:06 ` Lance Yang
2026-06-09 13:42 ` Nico Pache
2026-06-09 13:49 ` xu.xin16
2026-06-09 14:14 ` Lorenzo Stoakes
2026-06-09 14:26 ` Lorenzo Stoakes
2026-06-09 11:46 ` [PATCH mm-unstable v1 3/3] mm/huge_memory.c: Skip zero-page remapping when underused THP shrinker is disabled Nico Pache
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=16f9ea47-99c0-4483-a12f-190047c1411f@kernel.org \
--to=david@kernel.org \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=byungchul@sk.com \
--cc=chengming.zhou@linux.dev \
--cc=dev.jain@arm.com \
--cc=gourry@gourry.net \
--cc=joshua.hahnjy@gmail.com \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=matthew.brost@intel.com \
--cc=npache@redhat.com \
--cc=rakie.kim@sk.com \
--cc=ryan.roberts@arm.com \
--cc=usama.arif@linux.dev \
--cc=usamaarif642@gmail.com \
--cc=xu.xin16@zte.com.cn \
--cc=ying.huang@linux.alibaba.com \
--cc=yuzhao@google.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
all inboxes | Powered by JetHome®