All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nico Pache <nico.pache@linux.dev>
To: "David Hildenbrand (Arm)" <david@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.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>,
	Barry Song <baohua@kernel.org>, 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: Wed, 18 Nov 2026 23:09:59 -0700	[thread overview]
Message-ID: <657f9c70-ce3d-4424-b5f1-264469131b1a@linux.dev> (raw)
In-Reply-To: <8c0ce90d-74d8-4578-bfc9-9218fcae8165@kernel.org>



On 11/17/26 3:00 AM, David Hildenbrand (Arm) wrote:
> On 11/17/26 00:08, Nico Pache wrote:
>>
>>
>> On 11/16/26 3:30 PM, David Hildenbrand (Arm) wrote:
>>> On 10/25/26 18:39, Nico Pache (Red Hat) 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>
>>>> ---
>>>>    mm/huge_memory.c | 3 ++-
>>>>    1 file changed, 2 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>>>> index bd44d58e8684..2d56d1bff0ea 100644
>>>> --- a/mm/huge_memory.c
>>>> +++ b/mm/huge_memory.c
>>>> @@ -4104,7 +4104,8 @@ static int __folio_freeze_split_anon(struct folio *folio,
>>>>    out_no_split:
>>>>        local_irq_enable();
>>>>        if (anon_vma) {
>>>> -        if (!ret && !folio_is_device_private(folio))
>>>> +        if (!ret && !folio_is_device_private(folio) &&
>>>> +            split_underused_thp)
>>>>                ttu_flags = TTU_USE_SHARED_ZEROPAGE;
>>>>            remap_anon_folio(folio, 1 << old_order, ttu_flags);
>>>>        }
>>>>
>>>
>>> I guess the change is not that relevant in practice, because I suspect most
>>> people always run with split_underused_thp=true
>>
>> Yeah these two patches are only tangentially related. Technically with this
>> patch (1), disabling the underutilized shrinker would indeed fix it, as we no
>> longer are doing zero-page remapping. But the root cause is the split initiated
>> from KSM.
>>
>> Most people always run with split_underused_thp=true, but they also run with 511
>> max_pte_nones.
>>>
>>> Th question is whether "split_underused_thp" only determines "that we trigger a
>>> split if underused", or also "what to do when splitting a folio".
>>>
>>> Yes, it was added for the deferred shrinker, but the semantics of the toggle are
>>> not quite clear. I don't think there is any documentation for it ...
>>
>> Yeah Im not really sure if the intentions were to make all the splits do this
>> zero-page remapping. And im not fully aware either of the potential impact to
>> the system (whether positive or negative) this could have system wide. You could
>> argue it keeps better system utilization, but you could also argue the cmp is
>> expensive.
>>
>>>
>>> Disabling the "split to zeropage" entirely with the toggle off (behavior before
>>> the toggle was introduced) makes sense to me.
>>>
>>> But the behavior now already like that in the kernel for a while.
>>>
>>>
>>> I know that I suggested this, but I wonder, is this patch relevant for your use
>>> case and patch #2?
>>
>> Technically patch #2 solves the issue im actually trying to tackle. But during
>> this case we also found this functional change which we werent sure if it was
>> intended or not. As you say its poorly defined.
>>
>> Im ok with or without this patch. Perhaps we can take patch #2 (bar'ing review),
>> and I can try to do some perf testing regarding the effect of this zeropage
>> remapping system wide, and base our judgement off that.
> 
> Okay, then let's focus on patch #3. The semantics of this toggle here are rather
> akward (and I'd suspect we might just get rid of it at some point).

I assume you meant patch #2 ;P Ok sounds good I'll drop this patch for 
now! Thanks

> 


  reply	other threads:[~2026-11-19  6:10 UTC|newest]

Thread overview: 19+ 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
2026-10-26 17:41   ` sashiko-bot
2026-11-16 22:30   ` David Hildenbrand (Arm)
2026-11-16 23:08     ` Nico Pache
2026-11-17 10:00       ` David Hildenbrand (Arm)
2026-11-19  6:09         ` 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)
2026-11-16 22:21   ` David Hildenbrand (Arm)
2026-11-16 23:58     ` Nico Pache
2026-11-17  1:02       ` Xu Xin (vivo)
2026-11-18 21:27   ` Usama Arif
2026-11-19  6:18     ` 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=657f9c70-ce3d-4424-b5f1-264469131b1a@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 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.