From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: David Hildenbrand <david@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Andrew Morton <akpm@linux-foundation.org>,
Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Nico Pache <npache@redhat.com>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Barry Song <baohua@kernel.org>,
Usama Arif <usamaarif642@gmail.com>
Subject: Re: [PATCH v1] mm/huge_memory: fix shrinking of all-zero THPs with max_ptes_none default
Date: Mon, 8 Sep 2025 12:32:34 +0100 [thread overview]
Message-ID: <beda2005-f83f-42d4-8769-e719ece50866@lucifer.local> (raw)
In-Reply-To: <ebb2a888-a111-4c27-925e-58bfa8e07852@redhat.com>
On Fri, Sep 05, 2025 at 05:36:01PM +0200, David Hildenbrand wrote:
> On 05.09.25 17:30, Lorenzo Stoakes wrote:
> > On Fri, Sep 05, 2025 at 04:11:37PM +0200, David Hildenbrand wrote:
> > > We added an early exit in thp_underused(), probably to avoid scanning
> > > pages when there is no chance for success.
> > >
> > > However, assume we have max_ptes_none = 511 (default).
> > >
> > > Nothing should stop us from freeing all pages part of a THP that
> >
> > Freeing 'all pages which are part of a THP' rather?
>
> I'm German, I don't know what I'm doing. :D
Whereas I have no excuse :P
>
> >
> > > is completely zero (512) and khugepaged will for sure not try to
> >
> > that is -> that are?
>
> the THP is zero?
I mean "all pages part of a THP that is completely zero' -> "all pages part of a
THP that are completely zero', I'm referring to the 'all pages' bit, but I guess
you mean the THP is entirely zero.
So maybe rephrase to 'all pages which are part of a zero THP' or similar? :)
>
> >
> > > instantiate a THP in that case (512 shared zeropages).
> >
> > But if you write faulted they're not the zero page? And how are they shared? I
> > mean be being dumb here.
>
> The shrinker will replace zeroed pages by the shared zeropages.
Ah thanks, I was being dumb :) too stuck in vanilla mm land...
>
> >
> > >
> > > This can just trivially happen if someone writes a single 0 byte into a
> > > PMD area, or of course, when data ends up being zero later.
> > >
> > > So let's remove that early exit.
> > >
> > > Do we want to CC stable? Hm, not sure. Probably not urgent.
> >
> > Surely this is worth having?
>
> Alrighty, let me cc stable.
Thanks!
>
> >
> > >
> > > Note that, as default, the THP shrinker is active
> > > (/sys/kernel/mm/transparent_hugepage/shrink_underused = 1), and all
> > > THPs are added to the deferred split lists. However, with the
> > > max_ptes_none default we would never scan them. We would not do that. If
> >
> > Nit but 'we would not do that' is kinda duplicative here :)
>
> Yeah, fixed it already while rewriting: this was meant to be "would now".
Cheers!
>
>
> Thanks!
>
>
> --
> Cheers
>
> David / dhildenb
>
Cheers, Lorenzo
next prev parent reply other threads:[~2025-09-08 11:32 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 14:11 David Hildenbrand
2025-09-05 14:37 ` Zi Yan
2025-09-05 14:39 ` David Hildenbrand
2025-09-06 6:35 ` Lance Yang
2025-09-05 14:43 ` Usama Arif
2025-09-05 14:47 ` David Hildenbrand
2025-09-05 14:58 ` Usama Arif
2025-09-05 14:40 ` Usama Arif
2025-09-05 14:46 ` David Hildenbrand
2025-09-05 14:53 ` Usama Arif
2025-09-05 14:58 ` David Hildenbrand
2025-09-05 15:01 ` Usama Arif
2025-09-05 15:04 ` David Hildenbrand
2025-09-05 15:16 ` Usama Arif
2025-09-05 15:28 ` David Hildenbrand
2025-09-05 15:53 ` Usama Arif
2025-09-05 15:57 ` Usama Arif
2025-09-05 15:58 ` David Hildenbrand
2025-09-05 16:47 ` Usama Arif
2025-09-05 16:55 ` David Hildenbrand
2025-09-05 17:26 ` Usama Arif
2025-09-08 9:14 ` David Hildenbrand
2025-09-14 14:04 ` Dev Jain
2025-09-15 8:51 ` David Hildenbrand
2025-09-05 15:02 ` Usama Arif
2025-09-05 15:11 ` David Hildenbrand
2025-09-05 15:30 ` Lorenzo Stoakes
2025-09-05 15:36 ` David Hildenbrand
2025-09-08 11:32 ` Lorenzo Stoakes [this message]
2025-09-06 6:39 ` Lance Yang
2025-09-08 2:16 ` Baolin Wang
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=beda2005-f83f-42d4-8769-e719ece50866@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=dev.jain@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=npache@redhat.com \
--cc=ryan.roberts@arm.com \
--cc=usamaarif642@gmail.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