Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xen/balloon: improve accuracy of initial balloon target for dom0

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>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20260128110510.46425-3-roger.pau@citrix.com>

authored by

Roger Pau Monne and committed by
Juergen Gross
b13cd24c 0949c646

+17 -10
+17 -10
drivers/xen/balloon.c
··· 724 724 static int __init balloon_init(void) 725 725 { 726 726 struct task_struct *task; 727 - unsigned long current_pages; 727 + long current_pages = 0; 728 + domid_t domid = DOMID_SELF; 728 729 int rc; 729 730 730 731 if (!xen_domain()) ··· 733 732 734 733 pr_info("Initialising balloon driver\n"); 735 734 736 - if (xen_pv_domain()) { 737 - if (xen_released_pages >= xen_start_info->nr_pages) 738 - goto underflow; 739 - current_pages = min(xen_start_info->nr_pages - 740 - xen_released_pages, max_pfn); 741 - } else { 742 - if (xen_unpopulated_pages >= get_num_physpages()) 743 - goto underflow; 744 - current_pages = get_num_physpages() - xen_unpopulated_pages; 735 + if (xen_initial_domain()) 736 + current_pages = HYPERVISOR_memory_op(XENMEM_current_reservation, 737 + &domid); 738 + if (current_pages <= 0) { 739 + if (xen_pv_domain()) { 740 + if (xen_released_pages >= xen_start_info->nr_pages) 741 + goto underflow; 742 + current_pages = min(xen_start_info->nr_pages - 743 + xen_released_pages, max_pfn); 744 + } else { 745 + if (xen_unpopulated_pages >= get_num_physpages()) 746 + goto underflow; 747 + current_pages = get_num_physpages() - 748 + xen_unpopulated_pages; 749 + } 745 750 } 746 751 747 752 balloon_stats.current_pages = current_pages;