From: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: "Jürgen Groß" <jgross@suse.com>,
xen-devel <xen-devel@lists.xenproject.org>,
"Boris Ostrovsky" <boris.ostrovsky@oracle.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Vlastimil Babka" <vbabka@suse.cz>,
linux-mm@kvack.org
Subject: Re: Excluding init_on_free for pages for initial balloon down (Xen)
Date: Mon, 2 Mar 2026 16:11:02 +0100 [thread overview]
Message-ID: <aaWohimzb5P8n0YU@mail-itl> (raw)
In-Reply-To: <663cff60-8181-4a47-beff-204bfe01bb06@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 2398 bytes --]
On Mon, Mar 02, 2026 at 03:54:12PM +0100, David Hildenbrand (Arm) wrote:
> >
> >> Whatever leaves the buddy shall be zeroed out. If there is a
> >> double-zeroing happen, the latter could get optimized out by checking
> >> something like user_alloc_needs_zeroing().
> >>
> >> See mm/huge_memory.c:vma_alloc_anon_folio_pmd() as an example where we
> >> avoid double-zeroing.
> >
> > It isn't just reducing double-zeroing to single zeroing. It's about
> > avoiding zeroing such pages at all. If a domU is started with
> > populate-on-demand, many (sometimes most) of its pages are populated in
> > EPT. The idea of PoD is to start guest with high static memory size, but
> > low actual allocation and fake it until balloon driver kicks in and make
> > the domU really not use more pages than it has. When balloon driver try
> > to return those pages to the hypervisor, normally it would just take
> > unallocated page one by one and made Linux not use them. But if _any_
> > zeroing is happening, each page first needs to be mapped to the guest by
> > the hypervisor (one trip through EPT), just to be removed from them a
> > moment later...
>
> The same is true for most balloon drivers, including virtio-balloon.
>
> So far nobody really cared about that, though, as init_on_free usually
> comes with such a high performance price tag that people in cheap VMs
> (where you overcommit etc) don't enable it.
>
> __GFP_BALLOON_OUT is just nasty.
>
> We could probably have a special allocation interface (not exposed to
> arbitrary kernel modules) and have things like mm/balloon.c consume that.
>
>
> IIUC, xen balloon does not use the memory balloon infrastructure,
> though.
Is there some fundamental reason for that? By looking at the code, the
migration to use mm/balloon.c shouldn't be that hard (famous last
words...).
> So we'd need some EXPORT_SYMBOL_FOR_MODULES() magic.
Then this wouldn't be necessary.
> Like an
>
> struct page *alloc_balloon_pages(gfp_t gfp, unsigned int order);
>
> Where we only support a subset of gfp flags, for example, to now having
> to deal with mempolicy.
>
> But it needs a bit of code to make it fly, so I am not sure if the page
> allocator wants to support that.
PS adding linux-mm, which I forgot initially...
--
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next parent reply other threads:[~2026-03-02 15:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <aaRVcVmtv2UBD-GF@mail-itl>
[not found] ` <513e624f-35c1-4d43-ba3f-c96af613d400@suse.com>
[not found] ` <224968e6-7236-4efe-bcc0-ab39ac0c6c45@kernel.org>
[not found] ` <aaVuB3x3y4ROr5XA@mail-itl>
[not found] ` <663cff60-8181-4a47-beff-204bfe01bb06@kernel.org>
2026-03-02 15:11 ` Marek Marczykowski-Górecki [this message]
2026-03-02 15:21 ` Jürgen Groß
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=aaWohimzb5P8n0YU@mail-itl \
--to=marmarek@invisiblethingslab.com \
--cc=akpm@linux-foundation.org \
--cc=boris.ostrovsky@oracle.com \
--cc=david@kernel.org \
--cc=jgross@suse.com \
--cc=linux-mm@kvack.org \
--cc=vbabka@suse.cz \
--cc=xen-devel@lists.xenproject.org \
/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