Skip to content

Commit a1901b4

Browse files
committed
Merge tag 'for-linus-5.18-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen fixlet from Juergen Gross: "A single cleanup patch for the Xen balloon driver" * tag 'for-linus-5.18-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen/balloon: don't use PV mode extra memory for zone device allocations
2 parents 3a69a44 + 262fc47 commit a1901b4

File tree

2 files changed

+23
-64
lines changed

2 files changed

+23
-64
lines changed

drivers/xen/balloon.c

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -689,29 +689,34 @@ void xen_free_ballooned_pages(unsigned int nr_pages, struct page **pages)
689689
}
690690
EXPORT_SYMBOL(xen_free_ballooned_pages);
691691

692-
#if defined(CONFIG_XEN_PV) && !defined(CONFIG_XEN_UNPOPULATED_ALLOC)
693-
static void __init balloon_add_region(unsigned long start_pfn,
694-
unsigned long pages)
692+
static void __init balloon_add_regions(void)
695693
{
694+
#if defined(CONFIG_XEN_PV)
695+
unsigned long start_pfn, pages;
696696
unsigned long pfn, extra_pfn_end;
697+
unsigned int i;
697698

698-
/*
699-
* If the amount of usable memory has been limited (e.g., with
700-
* the 'mem' command line parameter), don't add pages beyond
701-
* this limit.
702-
*/
703-
extra_pfn_end = min(max_pfn, start_pfn + pages);
699+
for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) {
700+
pages = xen_extra_mem[i].n_pfns;
701+
if (!pages)
702+
continue;
704703

705-
for (pfn = start_pfn; pfn < extra_pfn_end; pfn++) {
706-
/* totalram_pages and totalhigh_pages do not
707-
include the boot-time balloon extension, so
708-
don't subtract from it. */
709-
balloon_append(pfn_to_page(pfn));
710-
}
704+
start_pfn = xen_extra_mem[i].start_pfn;
711705

712-
balloon_stats.total_pages += extra_pfn_end - start_pfn;
713-
}
706+
/*
707+
* If the amount of usable memory has been limited (e.g., with
708+
* the 'mem' command line parameter), don't add pages beyond
709+
* this limit.
710+
*/
711+
extra_pfn_end = min(max_pfn, start_pfn + pages);
712+
713+
for (pfn = start_pfn; pfn < extra_pfn_end; pfn++)
714+
balloon_append(pfn_to_page(pfn));
715+
716+
balloon_stats.total_pages += extra_pfn_end - start_pfn;
717+
}
714718
#endif
719+
}
715720

716721
static int __init balloon_init(void)
717722
{
@@ -745,20 +750,7 @@ static int __init balloon_init(void)
745750
register_sysctl_table(xen_root);
746751
#endif
747752

748-
#if defined(CONFIG_XEN_PV) && !defined(CONFIG_XEN_UNPOPULATED_ALLOC)
749-
{
750-
int i;
751-
752-
/*
753-
* Initialize the balloon with pages from the extra memory
754-
* regions (see arch/x86/xen/setup.c).
755-
*/
756-
for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++)
757-
if (xen_extra_mem[i].n_pfns)
758-
balloon_add_region(xen_extra_mem[i].start_pfn,
759-
xen_extra_mem[i].n_pfns);
760-
}
761-
#endif
753+
balloon_add_regions();
762754

763755
task = kthread_run(balloon_thread, NULL, "xen-balloon");
764756
if (IS_ERR(task)) {

drivers/xen/unpopulated-alloc.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -230,39 +230,6 @@ void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages)
230230
}
231231
EXPORT_SYMBOL(xen_free_unpopulated_pages);
232232

233-
#ifdef CONFIG_XEN_PV
234-
static int __init init(void)
235-
{
236-
unsigned int i;
237-
238-
if (!xen_domain())
239-
return -ENODEV;
240-
241-
if (!xen_pv_domain())
242-
return 0;
243-
244-
/*
245-
* Initialize with pages from the extra memory regions (see
246-
* arch/x86/xen/setup.c).
247-
*/
248-
for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) {
249-
unsigned int j;
250-
251-
for (j = 0; j < xen_extra_mem[i].n_pfns; j++) {
252-
struct page *pg =
253-
pfn_to_page(xen_extra_mem[i].start_pfn + j);
254-
255-
pg->zone_device_data = page_list;
256-
page_list = pg;
257-
list_count++;
258-
}
259-
}
260-
261-
return 0;
262-
}
263-
subsys_initcall(init);
264-
#endif
265-
266233
static int __init unpopulated_init(void)
267234
{
268235
int ret;

0 commit comments

Comments
 (0)