From: "Roger Pau Monné" <roger@xenproject.org>
To: Matthias Goergens <matthias.goergens@gmail.com>
Cc: Juergen Gross <jgross@suse.com>,
xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org,
Yannick Martin <yannick.martin@okazoo.eu>,
Thorsten Leemhuis <regressions@leemhuis.info>,
Stefano Stabellini <sstabellini@kernel.org>,
Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Subject: Re: [PATCH] x86/xen: fix init of balloon stats for PV guests with memory != maxmem
Date: Wed, 5 Aug 2026 10:43:29 +0200 [thread overview]
Message-ID: <anL3sbvftMybnwBG@macbook.local> (raw)
In-Reply-To: <20260805044607.2564210-1-matthias.goergens@gmail.com>
On Wed, Aug 05, 2026 at 12:46:07PM +0800, Matthias Goergens wrote:
> Hi Roger,
>
> thanks for picking this up, and Juergen, thanks for the quick review. Two
> things I believe are still worth addressing; the Fixes: tag can of course
> also be fixed up on application.
>
> I think the Fixes: tag should point to 0949c646d646 ("Partial revert
> \"x86/xen: fix balloon target initialization for PVH dom0\""). Commit
> 87af633689ce changed the initial-page calculation and the extra-region
> subtraction together, so those two operations were coherent: the PV initial
> count then came from get_num_physpages(), which includes the extra regions.
> 0949c646d646 restored the PV start_info->nr_pages calculation, which
> excludes the extra regions, but retained the subtraction.
I've got the same doubts about which commit to reference in the Fixes
tag. Here is my reasoning for picking the original bogus commit, and
not the subsequent attempt at fixing it:
Even if 87af633689ce was coherent in the usage of initial pages vs
extra regions, it was still wrong, and that's why it was (partially)
reverted. I assume that anyone who picks the change in this patch
will also have picked 0949c646d646, otherwise they have a problem with
how they do backports.
> Its 6.12.y
> backport is also the reporter's identified regression, first seen in
> 6.12.75. Applying this patch in a tree that has 87af633689ce but not
> 0949c646d646 (for example a 6.17-based distro tree) would double-account
> the extra region.
Why would someone apply this fix but not the preceding one? It makes
no sense, you either pick backports consistently, or need to be very
careful at knowing what to pick (and assume that sometimes stuff will
break).
> This likely also wants Cc: stable@vger.kernel.org, since
> both 6.12.y and 6.18.y carry the 0949c646d646 regression.
>
> Separately, and not something this patch introduces: PVH dom0 has the same
> shape of problem on mainline since b13cd24c15d7. A successful
> XENMEM_current_reservation supplies current_pages for both PV and PVH dom0,
> and that count excludes the unpopulated xen_extra_mem, so the
> xen_pv_domain()-only branch leaves PVH dom0 subtracting those pages again
> (-ERANGE, or a silently wrong target, when CONFIG_XEN_UNPOPULATED_ALLOC=n
> leaves the regions for the balloon driver). I am happy to pursue that as
> its own thread once this one lands.
Hm, I see. Running a PVH dom0 without CONFIG_XEN_UNPOPULATED_ALLOC
will be a very bad idea anyway, as the kernel would likely end up
triggering an OOM as all pages would be ballooned out to create
grant/foreign mappings.
> Would it be safer to pass balloon_add_regions() an explicit indication of
> whether the chosen initial-page count includes the extra physmap regions?
> That would cover PV, PVH dom0, and the XENMEM_current_reservation fallback
> without deriving the accounting rule solely from the domain type. On
> hypercall failure PVH dom0 falls back to get_num_physpages(), which
> includes the extra regions, so keying the accounting on the source of the
> count keeps the fallback correct as well.
Possibly, this has grown organically to accommodate for the
lack of proper interface to do memory balloon accounting.
I will send v2 attempting to take care of the PVH corner case and the
error fallback. It's IMO best if we can get all the related fixes
here in a single patch to backport.
Thanks, Roger.
next prev parent reply other threads:[~2026-08-05 8:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 14:35 [PATCH] x86/xen: fix init of balloon stats for PV guests with memory != maxmem Roger Pau Monne
2026-08-03 14:12 ` Juergen Gross
2026-08-05 4:46 ` Matthias Goergens
2026-08-05 8:43 ` Roger Pau Monné [this message]
2026-08-05 9:40 ` [PATCH v2] x86/xen: fix init of balloon stats again Roger Pau Monne
2026-08-05 11:50 ` Matthias Goergens
2026-08-05 12:04 ` Juergen Gross
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=anL3sbvftMybnwBG@macbook.local \
--to=roger@xenproject.org \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthias.goergens@gmail.com \
--cc=oleksandr_tyshchenko@epam.com \
--cc=regressions@leemhuis.info \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
--cc=yannick.martin@okazoo.eu \
/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