mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jürgen Groß" <jgross@suse.com>
To: Roger Pau Monne <roger.pau@citrix.com>,
	xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Subject: Re: [PATCH 2/2] xen/balloon: improve accuracy of initial balloon target for dom0
Date: Wed, 28 Jan 2026 12:31:13 +0100	[thread overview]
Message-ID: <596b08db-dc0e-4d42-ac17-570ca6e06bca@suse.com> (raw)
In-Reply-To: <20260128110510.46425-3-roger.pau@citrix.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 2542 bytes --]

On 28.01.26 12:05, Roger Pau Monne wrote:
> The dom0 balloon target set by the toolstack is the value returned by
> XENMEM_current_reservation.  Do the same in the kernel balloon driver and
> set the current allocation to the value returned by
> XENMEM_current_reservation.  On my test system this causes the kernel
> balloon driver target to exactly match the value set by the toolstack in
> xenstore.
> 
> Note this approach can be used by both PV and PVH dom0s, as the toolstack
> always uses XENMEM_current_reservation to set the initial target regardless
> of the dom0 type.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
>   drivers/xen/balloon.c | 27 +++++++++++++++++----------
>   1 file changed, 17 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
> index 8c44a25a7d2b..9b6531eb28b6 100644
> --- a/drivers/xen/balloon.c
> +++ b/drivers/xen/balloon.c
> @@ -724,7 +724,8 @@ static int __init balloon_add_regions(void)
>   static int __init balloon_init(void)
>   {
>   	struct task_struct *task;
> -	unsigned long current_pages;
> +	long current_pages = 0;
> +	domid_t domid = DOMID_SELF;
>   	int rc;
>   
>   	if (!xen_domain())
> @@ -732,15 +733,21 @@ static int __init balloon_init(void)
>   
>   	pr_info("Initialising balloon driver\n");
>   
> -	if (xen_pv_domain()) {
> -		if (xen_released_pages >= xen_start_info->nr_pages)
> -			goto underflow;
> -		current_pages = min(xen_start_info->nr_pages -
> -		                    xen_released_pages, max_pfn);
> -	} else {
> -		if (xen_unpopulated_pages >= get_num_physpages())
> -			goto underflow;
> -		current_pages = get_num_physpages() - xen_unpopulated_pages;
> +	if (xen_initial_domain())
> +		current_pages = HYPERVISOR_memory_op(XENMEM_current_reservation,
> +		                                     &domid);

Is there any specific reason why this should be limited to dom0?

I _think_ this should work for other domains, too.


Juergen

> +	if (current_pages <= 0) {
> +		if (xen_pv_domain()) {
> +			if (xen_released_pages >= xen_start_info->nr_pages)
> +				goto underflow;
> +			current_pages = min(xen_start_info->nr_pages -
> +			                    xen_released_pages, max_pfn);
> +		} else {
> +			if (xen_unpopulated_pages >= get_num_physpages())
> +				goto underflow;
> +			current_pages = get_num_physpages() -
> +			                xen_unpopulated_pages;
> +		}
>   	}
>   
>   	balloon_stats.current_pages = current_pages;


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

  reply	other threads:[~2026-01-28 11:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28 11:05 [PATCH 0/2] xen/balloon: fix balloon driver initial target Roger Pau Monne
2026-01-28 11:05 ` [PATCH 1/2] Partial revert "x86/xen: fix balloon target initialization for PVH dom0" Roger Pau Monne
2026-01-28 15:23   ` Jürgen Groß
2026-01-28 11:05 ` [PATCH 2/2] xen/balloon: improve accuracy of initial balloon target for dom0 Roger Pau Monne
2026-01-28 11:31   ` Jürgen Groß [this message]
2026-01-28 11:54     ` Roger Pau Monné
2026-01-28 15:18       ` Jürgen Groß
2026-01-28 15:23   ` 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=596b08db-dc0e-4d42-ac17-570ca6e06bca@suse.com \
    --to=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --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

all inboxes | Powered by JetHome®