xen/balloon: make alloc_xenballoon_pages() always allocate low pages
authorDavid Vrabel <david.vrabel@citrix.com>
Thu, 25 Jun 2015 12:12:46 +0000 (13:12 +0100)
committerDavid Vrabel <david.vrabel@citrix.com>
Fri, 23 Oct 2015 13:20:05 +0000 (14:20 +0100)
All users of alloc_xenballoon_pages() wanted low memory pages, so
remove the option for high memory.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
arch/x86/xen/grant-table.c
drivers/xen/balloon.c
drivers/xen/grant-table.c
drivers/xen/privcmd.c
drivers/xen/xenbus/xenbus_client.c
include/xen/balloon.h

index 1580e7a5a4cf7600d0f424ddd5a66d76efef6b2f..e079500b17f37accbc12c73e655e9584cc48953b 100644 (file)
@@ -133,7 +133,7 @@ static int __init xlated_setup_gnttab_pages(void)
                kfree(pages);
                return -ENOMEM;
        }
-       rc = alloc_xenballooned_pages(nr_grant_frames, pages, 0 /* lowmem */);
+       rc = alloc_xenballooned_pages(nr_grant_frames, pages);
        if (rc) {
                pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
                        nr_grant_frames, rc);
index ac6391bd8029c5836906f9cd8be1ecb2b6061896..7ec933d505d202fd0bd17b4d714f5e257d9187cb 100644 (file)
@@ -136,17 +136,16 @@ static void balloon_append(struct page *page)
 }
 
 /* balloon_retrieve: rescue a page from the balloon, if it is not empty. */
-static struct page *balloon_retrieve(bool prefer_highmem)
+static struct page *balloon_retrieve(bool require_lowmem)
 {
        struct page *page;
 
        if (list_empty(&ballooned_pages))
                return NULL;
 
-       if (prefer_highmem)
-               page = list_entry(ballooned_pages.prev, struct page, lru);
-       else
-               page = list_entry(ballooned_pages.next, struct page, lru);
+       page = list_entry(ballooned_pages.next, struct page, lru);
+       if (require_lowmem && PageHighMem(page))
+               return NULL;
        list_del(&page->lru);
 
        if (PageHighMem(page))
@@ -521,24 +520,20 @@ 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: allow highmem pages
  * @return 0 on success, error otherwise
  */
-int alloc_xenballooned_pages(int nr_pages, struct page **pages, bool highmem)
+int alloc_xenballooned_pages(int nr_pages, struct page **pages)
 {
        int pgno = 0;
        struct page *page;
        mutex_lock(&balloon_mutex);
        while (pgno < nr_pages) {
-               page = balloon_retrieve(highmem);
-               if (page && (highmem || !PageHighMem(page))) {
+               page = balloon_retrieve(true);
+               if (page) {
                        pages[pgno++] = page;
                } else {
                        enum bp_state st;
-                       if (page)
-                               balloon_append(page);
-                       st = decrease_reservation(nr_pages - pgno,
-                                       highmem ? GFP_HIGHUSER : GFP_USER);
+                       st = decrease_reservation(nr_pages - pgno, GFP_USER);
                        if (st != BP_DONE)
                                goto out_undo;
                }
index 62f591f8763ccfd4519248566b6f1d49eb78ce64..a4b702c9ac685c7050d02bc46121c6990ee28191 100644 (file)
@@ -687,7 +687,7 @@ int gnttab_alloc_pages(int nr_pages, struct page **pages)
        int i;
        int ret;
 
-       ret = alloc_xenballooned_pages(nr_pages, pages, false);
+       ret = alloc_xenballooned_pages(nr_pages, pages);
        if (ret < 0)
                return ret;
 
index 5e9adac928e694d6701b5c59ef5300144226a0ab..b199ad3d458777e4a390aacaea18a32df51e83a4 100644 (file)
@@ -401,7 +401,7 @@ static int alloc_empty_pages(struct vm_area_struct *vma, int numpgs)
        if (pages == NULL)
                return -ENOMEM;
 
-       rc = alloc_xenballooned_pages(numpgs, pages, 0);
+       rc = alloc_xenballooned_pages(numpgs, pages);
        if (rc != 0) {
                pr_warn("%s Could not alloc %d pfns rc:%d\n", __func__,
                        numpgs, rc);
index 2ba09c1195c87c68b47b2b210d6d0eb32c5ae056..aa304d05101ba7a90ad2055dd20cca44879b89a5 100644 (file)
@@ -614,8 +614,7 @@ static int xenbus_map_ring_valloc_hvm(struct xenbus_device *dev,
        if (!node)
                return -ENOMEM;
 
-       err = alloc_xenballooned_pages(nr_grefs, node->hvm.pages,
-                                      false /* lowmem */);
+       err = alloc_xenballooned_pages(nr_grefs, node->hvm.pages);
        if (err)
                goto out_err;
 
index c8aee7a8b8d2095910c4de3846fdf79467b0c5f6..83efdeb243bf87903e772c29c64eea5f2272d0f4 100644 (file)
@@ -22,8 +22,7 @@ extern struct balloon_stats balloon_stats;
 
 void balloon_set_new_target(unsigned long target);
 
-int alloc_xenballooned_pages(int nr_pages, struct page **pages,
-               bool highmem);
+int alloc_xenballooned_pages(int nr_pages, struct page **pages);
 void free_xenballooned_pages(int nr_pages, struct page **pages);
 
 struct device;