From: Nico Pache <nico.pache@linux.dev>
To: Barry Song <baohua@kernel.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>, Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Liam R. Howlett" <liam@infradead.org>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Lance Yang <lance.yang@linux.dev>,
Usama Arif <usama.arif@linux.dev>,
Kiryl Shutsemau <kas@kernel.org>, Yu Zhao <yuzhao@google.com>,
Xu Xin <xu.xin@linux.dev>,
Chengming Zhou <chengming.zhou@linux.dev>,
Matthew Brost <matthew.brost@intel.com>,
Joshua Hahn <joshua.hahnjy@gmail.com>,
Byungchul Park <byungchul@sk.com>,
Gregory Price <gourry@gourry.net>,
Ying Huang <ying.huang@linux.alibaba.com>,
Alistair Popple <apopple@nvidia.com>,
Usama Arif <usamaarif642@gmail.com>,
aarcange@redhat.com
Subject: Re: [PATCH v2 1/2] mm/huge_memory.c: skip zero-page remapping when underused THP shrinker is disabled
Date: Mon, 26 Oct 2026 15:33:46 -0600 [thread overview]
Message-ID: <a4dfbe84-aaf4-4711-8eac-6455470d1e7d@linux.dev> (raw)
In-Reply-To: <CAGsJ_4w4ozXM+=T0qGBAhC323F49Y4LxrrKKt3GFCs+en_TVCg@mail.gmail.com>
On 10/26/26 2:58 PM, Barry Song wrote:
> On Tue, Oct 27, 2026 at 4:02 AM Nico Pache <nico.pache@linux.dev> wrote:
>>
>>
>>
>> On 10/25/26 10:52 PM, Barry Song wrote:
>>> On Mon, Oct 26, 2026 at 5:48 AM Nico Pache <nico.pache@linux.dev> wrote:
>>>>
>>>>
>>>>
>>>> On 10/25/26 2:28 PM, Barry Song wrote:
>>>>> On Mon, Oct 26, 2026 at 1:40 AM Nico Pache (Red Hat)
>>>>> <nico.pache@linux.dev> wrote:
>>>>>>
>>>>>> The zero-page remapping in __folio_split() was added to support the
>>>>>> underused THP shrinker. When the shrinker is disabled via
>>>>>> shrink_underused, gate TTU_USE_SHARED_ZEROPAGE on split_underused_thp
>>>>>> to avoid scanning subpages for zero content unnecessarily.
>>>>>>
>>>>>> Suggested-by: David Hildenbrand <david@kernel.org>
>>>>>> Fixes: b1f202060afe ("mm: remap unused subpages to shared zeropage when splitting isolated thp")
>>>>>> Signed-off-by: Nico Pache <nico.pache@linux.dev>
>>>>>
>>>>> is b1f202060afe a correct fixes tag? as
>>>>> commit b1f202060afe has no even "split_underused_thp" there.
>>>>
>>>> I believe so. IIUC these two series were merged together. While
>>>> 81d3ff3c6f7 introduces the toggle, b1f202060afe is where the behavior
>>>> started.
>>>>
>>>> I guess you could argue that the Fixes should include both?
>>>>
>>>> Not entirely sure!
>>>
>>> Thanks for the clarification. I guess it's fine.
>>>
>>> BTW, with the code below, we no longer add fully mapped
>>> folios to deferred_split_folio. So the scanning code only
>>> handles partially mapped folios to set up zero-page mappings
>>> for their subpages.
>>>
>>> I'm still not quite sure whether this is really harmful, though.
>>> Am I missing something, or was there some discussion I missed?
>>
>> The issue is not in the actual shrinker code or the deferred split list.
>>
>> The issue is that any split leads to this zero-page remapping
>> indiscriminate of the actual toggle. The same way this toggle is gating
>> things going on the deferred split list, we should be gating the actual
>> zero-page remapping too.
>
> I'm not quite sure this is true. The toggle prevents fully mapped
> folios from being added to the deferred split list, so their
> subpages won't have a chance to be remapped to zero.
Correct, but the deferred split list is not the only caller of
folio_split(); all other callers get unconditional zero page remapping.
Additionally theres a difference between being fully mapped (and zero),
and being partially unmapped. the zero-page remapping checks the content
of the page. We could add folios to the deferred split list that are
fully mapped but contain mostly zeros. With shrinker_underused turned
off we no longer do any underutilized scans on reclaim, but other
splitters (KSM, vmscan, migration, etc) will still scan the content of
the memory and do the remapping whether this is on or off.
>
> For the remaining folios that are not fully mapped, or those
> that were added to deferred_split_list while the toggle was
> on and remain there after it is switched off, allowing
> remapping to zeropfn doesn't seem to violate the toggle's
> intention of preventing fully mapped folios from being added
> to deferred_split_list.
>
> Anyway, I don't have a strong opinion on this.
I think theres a misunderstanding here, but hopefully the above clears
it up :) if not just lmk!
Cheers,
-- Nico
>
> Thanks!
> Barry
next prev parent reply other threads:[~2026-10-26 21:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 17:39 [PATCH v2 0/2] MM: Tighten control over zero-page remapping Nico Pache (Red Hat)
2026-10-25 17:39 ` [PATCH v2 1/2] mm/huge_memory.c: skip zero-page remapping when underused THP shrinker is disabled Nico Pache (Red Hat)
2026-10-25 20:28 ` Barry Song
2026-10-25 21:48 ` Nico Pache
2026-10-26 4:52 ` Barry Song
2026-10-26 20:02 ` Nico Pache
2026-10-26 20:58 ` Barry Song
2026-10-26 21:33 ` Nico Pache [this message]
2026-10-25 17:39 ` [PATCH v2 2/2] mm/ksm: prevent zero-page remapping during ksmd-triggered THP splits Nico Pache (Red Hat)
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=a4dfbe84-aaf4-4711-8eac-6455470d1e7d@linux.dev \
--to=nico.pache@linux.dev \
--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=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=gourry@gourry.net \
--cc=joshua.hahnjy@gmail.com \
--cc=kas@kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=matthew.brost@intel.com \
--cc=ryan.roberts@arm.com \
--cc=usama.arif@linux.dev \
--cc=usamaarif642@gmail.com \
--cc=xu.xin@linux.dev \
--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®