xen: add an "highmem" parameter to alloc_xenballooned_pages
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>
Thu, 29 Sep 2011 10:57:55 +0000 (11:57 +0100)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Thu, 29 Sep 2011 13:56:52 +0000 (09:56 -0400)
Add an highmem parameter to alloc_xenballooned_pages, to allow callers to
request lowmem or highmem pages.

Fix the code style of free_xenballooned_pages' prototype.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/xen/balloon.c
drivers/xen/gntdev.c
include/xen/balloon.h

index 5dfd8f8ff07f402e9063b608c7e11b1b6571c126..cd8b4704ef4e79eff333816a5637194a427b453a 100644 (file)
@@ -501,20 +501,24 @@ EXPORT_SYMBOL_GPL(balloon_set_new_target);
  * alloc_xenballooned_pages - get pages that have been ballooned out
  * @nr_pages: Number of pages to get
  * @pages: pages returned
+ * @highmem: highmem or lowmem pages
  * @return 0 on success, error otherwise
  */
-int alloc_xenballooned_pages(int nr_pages, struct page** pages)
+int alloc_xenballooned_pages(int nr_pages, struct page **pages, bool highmem)
 {
        int pgno = 0;
        struct page* page;
        mutex_lock(&balloon_mutex);
        while (pgno < nr_pages) {
-               page = balloon_retrieve(true);
-               if (page) {
+               page = balloon_retrieve(highmem);
+               if (page && PageHighMem(page) == highmem) {
                        pages[pgno++] = page;
                } else {
                        enum bp_state st;
-                       st = decrease_reservation(nr_pages - pgno, GFP_HIGHUSER);
+                       if (page)
+                               balloon_append(page);
+                       st = decrease_reservation(nr_pages - pgno,
+                                       highmem ? GFP_HIGHUSER : GFP_USER);
                        if (st != BP_DONE)
                                goto out_undo;
                }
index f914b26cf0c2efdfac05b8af9e6d9b8a37124dfc..7b9b1d1b75a5bc433f4068d3c1b8aab749b23ac0 100644 (file)
@@ -123,7 +123,7 @@ static struct grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count)
            NULL == add->pages)
                goto err;
 
-       if (alloc_xenballooned_pages(count, add->pages))
+       if (alloc_xenballooned_pages(count, add->pages, false /* lowmem */))
                goto err;
 
        for (i = 0; i < count; i++) {
index 76f7538bb339be1c9cf3612e5721297f06af8acd..d29c153705bc92de6fa3ee80de9e91eaf913bbad 100644 (file)
@@ -25,8 +25,9 @@ extern struct balloon_stats balloon_stats;
 
 void balloon_set_new_target(unsigned long target);
 
-int alloc_xenballooned_pages(int nr_pages, struct page** pages);
-void free_xenballooned_pages(int nr_pages, struct page** pages);
+int alloc_xenballooned_pages(int nr_pages, struct page **pages,
+               bool highmem);
+void free_xenballooned_pages(int nr_pages, struct page **pages);
 
 struct sys_device;
 #ifdef CONFIG_XEN_SELFBALLOONING