]> xenbits.xensource.com Git - people/royger/linux.git/commitdiff
(no commit message) wip.balloon
authorRoger Pau Monne <roger.pau@citrix.com>
Mon, 30 Mar 2020 08:17:01 +0000 (10:17 +0200)
committerRoger Pau Monne <roger.pau@citrix.com>
Mon, 30 Mar 2020 09:12:24 +0000 (11:12 +0200)
drivers/xen/balloon.c

index 0c142bcab79d61d50e67a97862aecabe7c0542a2..d191a03c29e816d79e1688afdd3f1fe206402b6b 100644 (file)
@@ -284,6 +284,31 @@ static struct resource *additional_memory_resource(phys_addr_t size)
        return res;
 }
 
+static void balloon_add_region(unsigned long start_pfn,
+                              unsigned long pages)
+{
+       unsigned long pfn, extra_pfn_end;
+
+       /*
+        * 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);
+       if (extra_pfn_end == max_pfn)
+               printk("extra_pfn_end %lx max_pfn %lx new limit %lx\n",
+                      extra_pfn_end, max_pfn, start_pfn + pages);
+
+       for (pfn = start_pfn; pfn < extra_pfn_end; pfn++) {
+               /* totalram_pages and totalhigh_pages do not
+                  include the boot-time balloon extension, so
+                  don't subtract from it. */
+               balloon_append(pfn_to_page(pfn));
+       }
+
+       balloon_stats.total_pages += extra_pfn_end - start_pfn;
+}
+
 static enum bp_state reserve_additional_memory(void)
 {
        long credit;
@@ -356,7 +381,8 @@ static enum bp_state reserve_additional_memory(void)
                goto err;
        }
 
-       balloon_stats.total_pages += balloon_hotplug;
+       balloon_add_region(PFN_DOWN(resource->start),
+                          PFN_DOWN(resource->end - resource->start));
 
        return BP_WAIT;
   err:
@@ -631,6 +657,7 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages)
  out_undo:
        mutex_unlock(&balloon_mutex);
        free_xenballooned_pages(pgno, pages);
+       balloon_stats.target_unpopulated -= nr_pages - pgno;
        return ret;
 }
 EXPORT_SYMBOL(alloc_xenballooned_pages);
@@ -661,30 +688,6 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
 }
 EXPORT_SYMBOL(free_xenballooned_pages);
 
-#ifdef CONFIG_XEN_PV
-static void __init balloon_add_region(unsigned long start_pfn,
-                                     unsigned long pages)
-{
-       unsigned long pfn, extra_pfn_end;
-
-       /*
-        * 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++) {
-               /* totalram_pages and totalhigh_pages do not
-                  include the boot-time balloon extension, so
-                  don't subtract from it. */
-               balloon_append(pfn_to_page(pfn));
-       }
-
-       balloon_stats.total_pages += extra_pfn_end - start_pfn;
-}
-#endif
-
 static int __init balloon_init(void)
 {
        if (!xen_domain())