aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/balloon.c
diff options
context:
space:
mode:
authorDavid Vrabel <david.vrabel@citrix.com>2011-09-28 12:46:34 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-09-29 11:12:10 -0400
commit8b5d44a5ac93cd7a1b044db3ff0ba4955b4ba5ec (patch)
tree3db094063c6ae765704414a0d84bc8a009c4c2d6 /drivers/xen/balloon.c
parentb1cbf9b1d6af22ba262d99abcfd71d5d90dbd57a (diff)
xen: allow balloon driver to use more than one memory region
Allow the xen balloon driver to populate its list of extra pages from more than one region of memory. This will allow platforms to provide (for example) a region of low memory and a region of high memory. The maximum possible number of extra regions is 128 (== E820MAX) which is quite large so xen_extra_mem is placed in __initdata. This is safe as both xen_memory_setup() and balloon_init() are in __init. The balloon regions themselves are not altered (i.e., there is still only the one region). Signed-off-by: David Vrabel <david.vrabel@citrix.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen/balloon.c')
-rw-r--r--drivers/xen/balloon.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 9efb993090aa..fc43b53651d7 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -555,11 +555,32 @@ void free_xenballooned_pages(int nr_pages, struct page** pages)
555} 555}
556EXPORT_SYMBOL(free_xenballooned_pages); 556EXPORT_SYMBOL(free_xenballooned_pages);
557 557
558static int __init balloon_init(void) 558static void __init balloon_add_region(unsigned long start_pfn,
559 unsigned long pages)
559{ 560{
560 unsigned long pfn, extra_pfn_end; 561 unsigned long pfn, extra_pfn_end;
561 struct page *page; 562 struct page *page;
562 563
564 /*
565 * If the amount of usable memory has been limited (e.g., with
566 * the 'mem' command line parameter), don't add pages beyond
567 * this limit.
568 */
569 extra_pfn_end = min(max_pfn, start_pfn + pages);
570
571 for (pfn = start_pfn; pfn < extra_pfn_end; pfn++) {
572 page = pfn_to_page(pfn);
573 /* totalram_pages and totalhigh_pages do not
574 include the boot-time balloon extension, so
575 don't subtract from it. */
576 __balloon_append(page);
577 }
578}
579
580static int __init balloon_init(void)
581{
582 int i;
583
563 if (!xen_domain()) 584 if (!xen_domain())
564 return -ENODEV; 585 return -ENODEV;
565 586
@@ -587,23 +608,12 @@ static int __init balloon_init(void)
587 608
588 /* 609 /*
589 * Initialize the balloon with pages from the extra memory 610 * Initialize the balloon with pages from the extra memory
590 * region (see arch/x86/xen/setup.c). 611 * regions (see arch/x86/xen/setup.c).
591 *
592 * If the amount of usable memory has been limited (e.g., with
593 * the 'mem' command line parameter), don't add pages beyond
594 * this limit.
595 */ 612 */
596 extra_pfn_end = min(max_pfn, 613 for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++)
597 (unsigned long)PFN_DOWN(xen_extra_mem_start 614 if (xen_extra_mem[i].size)
598 + xen_extra_mem_size)); 615 balloon_add_region(PFN_UP(xen_extra_mem[i].start),
599 for (pfn = PFN_UP(xen_extra_mem_start); 616 PFN_DOWN(xen_extra_mem[i].size));
600 pfn < extra_pfn_end;
601 pfn++) {
602 page = pfn_to_page(pfn);
603 /* totalram_pages and totalhigh_pages do not include the boot-time
604 balloon extension, so don't subtract from it. */
605 __balloon_append(page);
606 }
607 617
608 return 0; 618 return 0;
609} 619}