]> xenbits.xensource.com Git - people/julieng/linux-arm.git/commitdiff
xen/balloon: pre-allocate p2m entries for ballooned pages
authorDavid Vrabel <david.vrabel@citrix.com>
Wed, 22 Jul 2015 13:50:37 +0000 (14:50 +0100)
committerDavid Vrabel <david.vrabel@citrix.com>
Tue, 29 Sep 2015 16:00:05 +0000 (17:00 +0100)
Pages returned by alloc_xenballooned_pages() will be used for grant
mapping which will call set_phys_to_machine() (in PV guests).

Ballooned pages are set as INVALID_P2M_ENTRY in the p2m and thus may
be using the (shared) missing tables and a subsequent
set_phys_to_machine() will need to allocate new tables.

Since the grant mapping may be done from a context that cannot sleep,
the p2m entries must already be allocated.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
drivers/xen/balloon.c

index 7a13efdebf1d9e9e07900418e8aa535cac80cc85..5fd7ee10b77ef8c650270d3c4c47950e571d28f6 100644 (file)
@@ -592,6 +592,7 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages)
 {
        int pgno = 0;
        struct page *page;
+       int ret = -ENOMEM;
 
        mutex_lock(&balloon_mutex);
 
@@ -601,6 +602,11 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages)
                page = balloon_retrieve(true);
                if (page) {
                        pages[pgno++] = page;
+#ifdef CONFIG_XEN_HAVE_PVMMU
+                       ret = xen_alloc_p2m_entry(page_to_pfn(page));
+                       if (ret < 0)
+                               goto out_undo;
+#endif
                } else {
                        ret = add_ballooned_pages(nr_pages - pgno);
                        if (ret < 0)
@@ -612,7 +618,7 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages)
  out_undo:
        mutex_unlock(&balloon_mutex);
        free_xenballooned_pages(pgno, pages);
-       return -ENOMEM;
+       return ret;
 }
 EXPORT_SYMBOL(alloc_xenballooned_pages);