aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
authorDavid Vrabel <david.vrabel@citrix.com>2011-09-28 17:46:34 +0100
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-09-29 11:12:10 -0400
commit8b5d44a5ac93cd7a1b044db3ff0ba4955b4ba5ec (patch)
tree3db094063c6ae765704414a0d84bc8a009c4c2d6 /drivers/xen
parentb1cbf9b1d6af22ba262d99abcfd71d5d90dbd57a (diff)
downloadkernel_samsung_smdk4412-8b5d44a5ac93cd7a1b044db3ff0ba4955b4ba5ec.zip
kernel_samsung_smdk4412-8b5d44a5ac93cd7a1b044db3ff0ba4955b4ba5ec.tar.gz
kernel_samsung_smdk4412-8b5d44a5ac93cd7a1b044db3ff0ba4955b4ba5ec.tar.bz2
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')
-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 9efb993..fc43b53 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)
}
EXPORT_SYMBOL(free_xenballooned_pages);
-static int __init balloon_init(void)
+static void __init balloon_add_region(unsigned long start_pfn,
+ unsigned long pages)
{
unsigned long pfn, extra_pfn_end;
struct page *page;
+ /*
+ * If the amount of usable memory has been limited (e.g., with
+ * the 'mem' command line parameter), don't add pages beyond
+ * this limit.
+ */
+ extra_pfn_end = min(max_pfn, start_pfn + pages);
+
+ for (pfn = start_pfn; pfn < extra_pfn_end; pfn++) {
+ page = pfn_to_page(pfn);
+ /* totalram_pages and totalhigh_pages do not
+ include the boot-time balloon extension, so
+ don't subtract from it. */
+ __balloon_append(page);
+ }
+}
+
+static int __init balloon_init(void)
+{
+ int i;
+
if (!xen_domain())
return -ENODEV;
@@ -587,23 +608,12 @@ static int __init balloon_init(void)
/*
* Initialize the balloon with pages from the extra memory
- * region (see arch/x86/xen/setup.c).
- *
- * If the amount of usable memory has been limited (e.g., with
- * the 'mem' command line parameter), don't add pages beyond
- * this limit.
+ * regions (see arch/x86/xen/setup.c).
*/
- extra_pfn_end = min(max_pfn,
- (unsigned long)PFN_DOWN(xen_extra_mem_start
- + xen_extra_mem_size));
- for (pfn = PFN_UP(xen_extra_mem_start);
- pfn < extra_pfn_end;
- pfn++) {
- page = pfn_to_page(pfn);
- /* totalram_pages and totalhigh_pages do not include the boot-time
- balloon extension, so don't subtract from it. */
- __balloon_append(page);
- }
+ for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++)
+ if (xen_extra_mem[i].size)
+ balloon_add_region(PFN_UP(xen_extra_mem[i].start),
+ PFN_DOWN(xen_extra_mem[i].size));
return 0;
}