]> xenbits.xensource.com Git - legacy/linux-2.6.18-xen.git/commitdiff
xen/balloon: prefer using pages from balloon in alloc_empty_pages_and_pagevec()
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 16 Dec 2009 16:43:33 +0000 (16:43 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 16 Dec 2009 16:43:33 +0000 (16:43 +0000)
This is both faster and less demanding on kernel resources.

Likely also something that could be done in the pv-ops tree (though it
would need some adjustment to deal with the balloon_order!=0 case).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
drivers/xen/balloon/balloon.c

index 0bb27345ac806abf2fab6559925bb6860d2e2bba..cf1878c7fc6eb9c9248d3d9f6985b189f335e8cb 100644 (file)
@@ -602,6 +602,17 @@ struct page **alloc_empty_pages_and_pagevec(int nr_pages)
                return NULL;
 
        for (i = 0; i < nr_pages; i++) {
+               balloon_lock(flags);
+               page = balloon_first_page();
+               if (page && !PageHighMem(page)) {
+                       UNLIST_PAGE(page);
+                       bs.balloon_low--;
+                       balloon_unlock(flags);
+                       pagevec[i] = page;
+                       continue;
+               }
+               balloon_unlock(flags);
+
                page = pagevec[i] = alloc_page(GFP_KERNEL|__GFP_COLD);
                if (page == NULL)
                        goto err;