From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: "David Hildenbrand (Arm)" <david@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>,
Nico Pache <nico.pache@linux.dev>,
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>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Dan Williams <djbw@kernel.org>,
Matthew Wilcox <willy@infradead.org>,
Kees Cook <kees@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
linux-mm@kvack.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev,
Pankaj Raghav <pankaj.raghav@linux.dev>
Subject: Re: [PATCH RFC] mm/huge_memory: eliminate reference-counted huge zero folio
Date: Thu, 30 Jul 2026 11:06:33 +0100 [thread overview]
Message-ID: <amsf4_v4EDcU6ePJ@lucifer> (raw)
In-Reply-To: <04d881f4-419c-450e-b9b4-1341497fa93a@kernel.org>
On Tue, Jul 28, 2026 at 09:16:08PM +0200, David Hildenbrand (Arm) wrote:
> On 7/28/26 15:06, Lorenzo Stoakes (ARM) wrote:
> > The reference-counted huge zero folio is problematic - it's prone to subtle
> > races, it can introduce allocation latency and it is confusing and
> > complicated code.
>
> Just a note that the subject is misleading: the huge zero folio is always
> refcounted (e.g., GUP must take references), it's just that the persistent huge
> zero folio never drops the refcount to 0 to free it.
I meant huge_zero_refcount not folio refcount :) but maybe could have been
clearer.
>
> What you probably mean is "mm/huge_memory: eliminate dynamically allocated huge
> zero folio".
Well that's not really getting to the core of it, the problem is the
huge_zero_refcount meaning it can come and go and you have races.
But agreed refcount is imprecise + clearly confusing vs. folio refcount given
you immediately assuemd that.
So 'mm/huge_memory: eliminiate dynmaically alloc'd/freed huge zero folio' maybe?
>
> If we go down that path here, we can also teach GUP to not take a reference on
> the huge zero folio anymore on the FOLL_PIN path, similar to how we handle the
> zero folio.
>
> See the occurrences of is_zero_folio() in mm/gup.c.
Ah yeah. Can do that on a respin, thanks.
>
> The reason we do it for now for FOLL_PIN is that a remote pin might outlive the
> process, meaning the huge folio could otherwise get freed by the shrinker even
> though someone still holds a reference. Bad. So that would no longer apply if
> the huge zero folio can no longer get freed.
Incredible that we have to think about this...
>
>
> I recall there was a discussion (dropping dynamically allocated huge zero folio)
> on this topic while upstreaming the persistent huge zero folio.
>
> I don't have time right now to dig, but it would be worthwhile to look at that
> history if there was a good reason to keep it buried in that discussion.
Maybe this:
https://lore.kernel.org/all/20250811084113.647267-4-kernel@pankajraghav.com/T/#m4100481232bae8a7b661e8f6e86ecc74532c69a4
Generally seems 'smaller systems blah blah'. But smaller systems that set
CONFIG_THP get bigger reserves etc. so the argument doesn't really work.
I suppose they might default CONFIG_THP on but not enable THP but at that point
are you really so tiny a system that 2 MiB matters?
Obviously it's more problematic for 64 KiB page size, but then if you have THP
at all your reserves will already be problematic, and any read fault on a THP
page gets you the exact same issue.
>
> --
> Cheers,
>
> David
Cheers, Lorenzo
prev parent reply other threads:[~2026-07-30 10:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 13:06 [PATCH RFC] mm/huge_memory: eliminate reference-counted huge zero folio Lorenzo Stoakes (ARM)
2026-07-28 19:16 ` David Hildenbrand (Arm)
2026-07-30 10:06 ` Lorenzo Stoakes (ARM) [this message]
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=amsf4_v4EDcU6ePJ@lucifer \
--to=ljs@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=borntraeger@linux.ibm.com \
--cc=brauner@kernel.org \
--cc=bsegall@google.com \
--cc=corbet@lwn.net \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=djbw@kernel.org \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=jack@suse.cz \
--cc=juri.lelli@redhat.com \
--cc=kees@kernel.org \
--cc=kprateek.nayak@amd.com \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-s390@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=nico.pache@linux.dev \
--cc=nvdimm@lists.linux.dev \
--cc=pankaj.raghav@linux.dev \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=skhan@linuxfoundation.org \
--cc=surenb@google.com \
--cc=svens@linux.ibm.com \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=viro@zeniv.linux.org.uk \
--cc=vschneid@redhat.com \
--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 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.