]> xenbits.xensource.com Git - xen.git/commitdiff
Add an exact-node request flag for mem allocations.
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 5 Jul 2010 07:40:26 +0000 (08:40 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 5 Jul 2010 07:40:26 +0000 (08:40 +0100)
Signed-off-by : Dulloor <dulloor@gmail.com>

xen/common/memory.c
xen/common/page_alloc.c
xen/include/public/memory.h
xen/include/xen/mm.h

index c7caa074c056021cf6b290bb8c5f98315e1b1e12..924f07a1e15e4f32a8af5a5495fcda9d7d210485 100644 (file)
@@ -545,6 +545,8 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE(void) arg)
         }
 
         args.memflags |= MEMF_node(XENMEMF_get_node(reservation.mem_flags));
+        if (reservation.mem_flags & XENMEMF_exact_node_request)
+            args.memflags |= MEMF_exact_node;
 
         if ( op == XENMEM_populate_physmap
              && (reservation.mem_flags & XENMEMF_populate_on_demand) )
index 10c6b2209303f6ad15614ef7c0c9e2df738f2892..1588a2a092a5042f1e5100634a1adb9dff7fbfd4 100644 (file)
@@ -300,11 +300,15 @@ static struct page_info *alloc_heap_pages(
     unsigned int i, j, zone = 0;
     unsigned int num_nodes = num_online_nodes();
     unsigned long request = 1UL << order;
+    bool_t exact_node_request = !!(memflags & MEMF_exact_node);
     cpumask_t extra_cpus_mask, mask;
     struct page_info *pg;
 
     if ( node == NUMA_NO_NODE )
+    {
         node = cpu_to_node(smp_processor_id());
+        exact_node_request = 0;
+    }
 
     ASSERT(node >= 0);
     ASSERT(zone_lo <= zone_hi);
@@ -345,6 +349,9 @@ static struct page_info *alloc_heap_pages(
                     goto found;
         } while ( zone-- > zone_lo ); /* careful: unsigned zone may wrap */
 
+        if ( exact_node_request )
+            goto not_found;
+
         /* Pick next node, wrapping around if needed. */
         node = next_node(node, node_online_map);
         if (node == MAX_NUMNODES)
@@ -360,6 +367,7 @@ static struct page_info *alloc_heap_pages(
         return pg;
     }
 
+ not_found:
     /* No suitable memory blocks. Fail the request. */
     spin_unlock(&heap_lock);
     return NULL;
index 883a17d8ddb9681efca835ccaa409486bd80b9af..08355e3c3caba7a201ea11de9925ea71b06f0e67 100644 (file)
@@ -52,6 +52,9 @@
 #define XENMEMF_get_node(x) ((((x) >> 8) - 1) & 0xffu)
 /* Flag to populate physmap with populate-on-demand entries */
 #define XENMEMF_populate_on_demand (1<<16)
+/* Flag to request allocation only from the node specified */
+#define XENMEMF_exact_node_request  (1<<17)
+#define XENMEMF_exact_node(n) (XENMEMF_node(n) | XENMEMF_exact_node_request)
 #endif
 
 struct xen_memory_reservation {
index 612a11c39b6674409d8694bbf5b2916ab2df0301..63c47099f7999b47b8b9ff7eb74fd16addb83973 100644 (file)
@@ -82,6 +82,8 @@ int assign_pages(
 #define  MEMF_tmem        (1U<<_MEMF_tmem)
 #define _MEMF_no_dma      3
 #define  MEMF_no_dma      (1U<<_MEMF_no_dma)
+#define _MEMF_exact_node  4
+#define  MEMF_exact_node  (1U<<_MEMF_exact_node)
 #define _MEMF_node        8
 #define  MEMF_node(n)     ((((n)+1)&0xff)<<_MEMF_node)
 #define _MEMF_bits        24