[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Add slack to balloon driver to allow to counteract low-mem



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 41489189b19e20b3fda4222e1787821d990206bc
# Parent  c08e7f0b1ee597381d8c0dcca8a1b915b31bbc96
Add slack to balloon driver to allow to counteract low-mem
address space allocations in backend drivers.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r c08e7f0b1ee5 -r 41489189b19e 
linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c Wed Oct 19 12:42:55 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c Wed Oct 19 12:59:15 2005
@@ -939,6 +939,8 @@
        if ( xen_override_max_pfn < xen_start_info->nr_pages )
                xen_override_max_pfn = xen_start_info->nr_pages;
        max_pfn = xen_override_max_pfn;
+       /* 8MB slack, to make up for address space allocations in backends. */
+       max_pfn += 8 << (20 - PAGE_SHIFT);
 }
 #endif /* XEN */
 
@@ -1638,39 +1640,17 @@
 #endif
 
        /* Make sure we have a correctly sized P->M table. */
-       if (max_pfn != xen_start_info->nr_pages) {
-               phys_to_machine_mapping = alloc_bootmem_low_pages(
-                       max_pfn * sizeof(unsigned long));
-
-               if (max_pfn > xen_start_info->nr_pages) {
-                       /* set to INVALID_P2M_ENTRY */
-                       memset(phys_to_machine_mapping, ~0,
-                               max_pfn * sizeof(unsigned long));
-                       memcpy(phys_to_machine_mapping,
-                               (unsigned long *)xen_start_info->mfn_list,
-                               xen_start_info->nr_pages * sizeof(unsigned 
long));
-               } else {
-                       struct xen_memory_reservation reservation = {
-                               .extent_start = (unsigned long 
*)xen_start_info->mfn_list + max_pfn,
-                               .nr_extents   = xen_start_info->nr_pages - 
max_pfn,
-                               .extent_order = 0,
-                               .domid        = DOMID_SELF
-                       };
-
-                       memcpy(phys_to_machine_mapping,
-                               (unsigned long *)xen_start_info->mfn_list,
-                               max_pfn * sizeof(unsigned long));
-                       BUG_ON(HYPERVISOR_memory_op(
-                               XENMEM_decrease_reservation,
-                               &reservation) !=
-                           (xen_start_info->nr_pages - max_pfn));
-               }
-               free_bootmem(
-                       __pa(xen_start_info->mfn_list), 
-                       PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
-                       sizeof(unsigned long))));
-       }
-
+       phys_to_machine_mapping = alloc_bootmem_low_pages(
+               max_pfn * sizeof(unsigned long));
+       memset(phys_to_machine_mapping, ~0,
+               max_pfn * sizeof(unsigned long));
+       memcpy(phys_to_machine_mapping,
+               (unsigned long *)xen_start_info->mfn_list,
+               xen_start_info->nr_pages * sizeof(unsigned long));
+       free_bootmem(
+               __pa(xen_start_info->mfn_list), 
+               PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
+               sizeof(unsigned long))));
 
        /* 
         * Initialise the list of the frames that specify the list of 
diff -r c08e7f0b1ee5 -r 41489189b19e 
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c        Wed Oct 19 
12:42:55 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c        Wed Oct 19 
12:59:15 2005
@@ -528,10 +528,13 @@
 {
         unsigned long max_end_pfn = xen_start_info->nr_pages;
 
-       if ( xen_override_max_pfn <  max_end_pfn)
+       if ( xen_override_max_pfn < max_end_pfn)
                xen_override_max_pfn = max_end_pfn;
-       
-        return xen_override_max_pfn;
+
+       /* 8MB slack, to make up for address space allocations in backends. */
+       xen_override_max_pfn += 8 << (20 - PAGE_SHIFT);
+
+       return xen_override_max_pfn;
 }
 
 void __init e820_reserve_resources(void) 
diff -r c08e7f0b1ee5 -r 41489189b19e 
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c       Wed Oct 19 
12:42:55 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c       Wed Oct 19 
12:59:15 2005
@@ -429,7 +429,7 @@
 static void __init contig_initmem_init(void)
 {
         unsigned long bootmap_size = init_bootmem(start_pfn, end_pfn);
-        free_bootmem(0, end_pfn << PAGE_SHIFT);   
+        free_bootmem(0, xen_start_info->nr_pages << PAGE_SHIFT);
         reserve_bootmem(HIGH_MEMORY,
                         (PFN_PHYS(start_pfn) + bootmap_size + PAGE_SIZE-1)
                         - HIGH_MEMORY);
@@ -734,19 +734,17 @@
        {
                int i, j, k, fpp;
                /* Make sure we have a large enough P->M table. */
-               if (end_pfn > xen_start_info->nr_pages) {
-                       phys_to_machine_mapping = alloc_bootmem(
-                               end_pfn * sizeof(unsigned long));
-                       memset(phys_to_machine_mapping, ~0,
-                              end_pfn * sizeof(unsigned long));
-                       memcpy(phys_to_machine_mapping,
-                              (unsigned long *)xen_start_info->mfn_list,
-                              xen_start_info->nr_pages * sizeof(unsigned 
long));
-                       free_bootmem(
-                               __pa(xen_start_info->mfn_list), 
-                               PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
-                                               sizeof(unsigned long))));
-               }
+               phys_to_machine_mapping = alloc_bootmem(
+                       end_pfn * sizeof(unsigned long));
+               memset(phys_to_machine_mapping, ~0,
+                      end_pfn * sizeof(unsigned long));
+               memcpy(phys_to_machine_mapping,
+                      (unsigned long *)xen_start_info->mfn_list,
+                      xen_start_info->nr_pages * sizeof(unsigned long));
+               free_bootmem(
+                       __pa(xen_start_info->mfn_list), 
+                       PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
+                                       sizeof(unsigned long))));
 
                /* 
                 * Initialise the list of the frames that specify the list of 
diff -r c08e7f0b1ee5 -r 41489189b19e 
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Wed Oct 19 
12:42:55 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Wed Oct 19 
12:59:15 2005
@@ -502,7 +502,7 @@
                .extent_order = 0,
                .domid        = DOMID_SELF
        };
-       set_pte(pte, __pte_ma(0));
+       set_pte_at(&init_mm, addr, pte, __pte_ma(0));
        phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
                INVALID_P2M_ENTRY;
        BUG_ON(HYPERVISOR_memory_op(
@@ -521,10 +521,9 @@
 
        scrub_pages(vstart, 1 << order);
 
+       balloon_lock(flags);
        BUG_ON(generic_page_range(
                &init_mm, vstart, PAGE_SIZE << order, dealloc_pte_fn, NULL));
-
-       balloon_lock(flags);
        current_pages -= 1UL << order;
        balloon_unlock(flags);
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.