From: Mateusz Guzik <mjguzik@gmail.com>
To: "David Hildenbrand (Red Hat)" <david@kernel.org>
Cc: Li Zhe <lizhe.67@bytedance.com>,
akpm@linux-foundation.org, ankur.a.arora@oracle.com,
fvdl@google.com, joao.m.martins@oracle.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
mhocko@suse.com, muchun.song@linux.dev, osalvador@suse.de,
raghavendra.kt@amd.com
Subject: Re: [PATCH v2 0/8] Introduce a huge-page pre-zeroing mechanism
Date: Wed, 14 Jan 2026 14:06:54 +0100 [thread overview]
Message-ID: <CAGudoHEyxsPnJ2M+LWkPEb94L2Xp0iqH6O==hCUZE1woLzZB0Q@mail.gmail.com> (raw)
In-Reply-To: <1edfe356-8334-42d2-9d68-7c5bf21a01db@kernel.org>
On Wed, Jan 14, 2026 at 1:41 PM David Hildenbrand (Red Hat)
<david@kernel.org> wrote:
>
> On 1/14/26 13:33, David Hildenbrand (Red Hat) wrote:
> > On 1/14/26 13:11, Mateusz Guzik wrote:
> >> On Wed, Jan 14, 2026 at 12:55 PM David Hildenbrand (Red Hat)
> >> <david@kernel.org> wrote:
> >>> You said "I wonder if implementing hugepage pre-zeroing directly within
> >>> the kernel would be a simpler and more direct way to accelerate VM
> >>> creation".
> >>>
> >>> And I agree. But to make that fly (no user space polling interface), I
> >>> was wondering whether we could do it like "init_on_free" and let whoever
> >>> frees a hugetlb folio just reinitialize it with 0.
> >>>
> >>> No kernel thread, no user space thread involved.
> >>>
> >>
> >> i don't see how this is supposed to address the stated problem of
> >> zeroing being incredibly expensive.
> >
> > The price of zeroing has to be paid somewhere.
> >
Of course.
I'm stating that with dedicated threads for zeroing, provided there is
some memory available along with cpu time, it can be paid while
nothing actively needs these pages.
> > Currently it's done at allocation time, we could move it to freeing time.
> >
> > That would make application startup faster and application shutdown slower.
> >
> > And we're aware that application shutdown can be expensive, which is why
> > e.g., QEMU implements an async shutdown operation, where the MM gets
> > torn down from another process.
>
> Also, just to mention it, assuming a VM is backed by a hugetlb file, the
> user space thread destroying that file (or parts of it by punshing holes
> and freeing hugetlb folios) would be paying that price.
>
> That could be done whenever there is a CPU to spare to perform some freeing.
>
> But again, I think the main motivation here is "increase application
> startup", not optimize that the zeroing happens at specific points in
> time during system operation (e.g., when idle etc).
>
Framing this as "increase application startup" and merely shifting the
overhead to shutdown seems like gaming the problem statement to me.
The real problem is total real time spent on it while pages are
needed.
Support for background zeroing can give you more usable pages provided
it has the cpu + ram to do it. If it does not, you are in the worst
case in the same spot as with zeroing on free.
Let's take a look at some examples.
Say there are no free huge pages and you kill a vm + start a new one.
On top of that all CPUs are pegged as is. In this case total time is
the same for "zero on free" as it is for background zeroing.
Say the system is freshly booted and you start up a vm. There are no
pre-zeroed pages available so it suffers at start time no matter what.
However, with some support for background zeroing, the machinery could
respond to demand and do it in parallel in some capacity, shortening
the real time needed.
Say a little bit of real time passes and you start another vm. With
merely zeroing on free there are still no pre-zeroed pages available
so it again suffers the overhead. With background zeroing some of the
that memory would be already sorted out, speeding up said startup.
next prev parent reply other threads:[~2026-01-14 13:07 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-07 11:31 Li Zhe
2026-01-07 11:31 ` [PATCH v2 1/8] mm/hugetlb: add pre-zeroed framework Li Zhe
2026-01-07 11:31 ` [PATCH v2 2/8] mm/hugetlb: convert to prep_account_new_hugetlb_folio() Li Zhe
2026-01-07 11:31 ` [PATCH v2 3/8] mm/hugetlb: move the huge folio to the end of the list during enqueue Li Zhe
2026-01-07 11:31 ` [PATCH v2 4/8] mm/hugetlb: introduce per-node sysfs interface "zeroable_hugepages" Li Zhe
2026-01-07 11:31 ` [PATCH v2 5/8] mm/hugetlb: simplify function hugetlb_sysfs_add_hstate() Li Zhe
2026-01-07 11:31 ` [PATCH v2 6/8] mm/hugetlb: relocate the per-hstate struct kobject pointer Li Zhe
2026-01-07 11:31 ` [PATCH v2 7/8] mm/hugetlb: add epoll support for interface "zeroable_hugepages" Li Zhe
2026-01-07 11:31 ` [PATCH v2 8/8] mm/hugetlb: limit event generation frequency of function do_zero_free_notify() Li Zhe
2026-01-07 16:19 ` [PATCH v2 0/8] Introduce a huge-page pre-zeroing mechanism Andrew Morton
2026-01-12 11:25 ` Li Zhe
2026-01-09 6:05 ` Muchun Song
2026-01-12 11:27 ` Li Zhe
2026-01-12 19:52 ` David Hildenbrand (Red Hat)
2026-01-13 6:37 ` Li Zhe
2026-01-13 10:15 ` David Hildenbrand (Red Hat)
2026-01-13 12:41 ` Li Zhe
2026-01-14 10:41 ` David Hildenbrand (Red Hat)
2026-01-14 11:36 ` Li Zhe
2026-01-14 11:55 ` David Hildenbrand (Red Hat)
2026-01-14 12:11 ` Mateusz Guzik
2026-01-14 12:33 ` David Hildenbrand (Red Hat)
2026-01-14 12:41 ` David Hildenbrand (Red Hat)
2026-01-14 13:06 ` Mateusz Guzik [this message]
2026-01-12 22:00 ` Ankur Arora
2026-01-13 6:39 ` Li Zhe
2026-01-12 22:01 ` Ankur Arora
2026-01-13 6:41 ` Li Zhe
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='CAGudoHEyxsPnJ2M+LWkPEb94L2Xp0iqH6O==hCUZE1woLzZB0Q@mail.gmail.com' \
--to=mjguzik@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ankur.a.arora@oracle.com \
--cc=david@kernel.org \
--cc=fvdl@google.com \
--cc=joao.m.martins@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizhe.67@bytedance.com \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=raghavendra.kt@amd.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