xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 02/11] [XEN] exact node request
@ 2010-04-04 19:30 Dulloor
  2010-04-07 11:51 ` Andre Przywara
  0 siblings, 1 reply; 2+ messages in thread
From: Dulloor @ 2010-04-04 19:30 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 338 bytes --]

Currently, xen might allocate memory from other nodes (if allocation
from requested node fails) even if the memflags specifies a node. For
initial memory allocation and certain other purposes, stricter
semantics are needed. The patch implements exact_node_request flag for
this.

-dulloor

Signed-off-by: Dulloor Rao <dulloor@gatech.edu>

[-- Attachment #2: xen-02-exact-node-request.patch --]
[-- Type: text/x-patch, Size: 3008 bytes --]

diff -r dd0cdf8346df -r 9a3efacb9e39 xen/common/memory.c
--- a/xen/common/memory.c	Tue Mar 30 18:03:27 2010 -0400
+++ b/xen/common/memory.c	Tue Mar 30 18:51:31 2010 -0400
@@ -545,6 +545,8 @@
         }
 
         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) )
diff -r dd0cdf8346df -r 9a3efacb9e39 xen/common/page_alloc.c
--- a/xen/common/page_alloc.c	Tue Mar 30 18:03:27 2010 -0400
+++ b/xen/common/page_alloc.c	Tue Mar 30 18:51:31 2010 -0400
@@ -300,11 +300,16 @@
     unsigned int i, j, zone = 0;
     unsigned int num_nodes = num_online_nodes();
     unsigned long request = 1UL << order;
+    unsigned int exact_node_request;
     cpumask_t extra_cpus_mask, mask;
     struct page_info *pg;
 
-    if ( node == NUMA_NO_NODE )
+    if ( node == NUMA_NO_NODE ) {
         node = cpu_to_node(smp_processor_id());
+        exact_node_request = 0;
+    } else {
+        exact_node_request = (memflags & MEMF_exact_node); 
+    }
 
     ASSERT(node >= 0);
     ASSERT(zone_lo <= zone_hi);
@@ -342,13 +347,15 @@
                     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)
             node = first_node(node_online_map);
     }
 
- try_tmem:
+try_tmem:
     /* Try to free memory from tmem */
     if ( (pg = tmem_relinquish_pages(order,memflags)) != NULL )
     {
@@ -357,6 +364,7 @@
         return pg;
     }
 
+not_found:
     /* No suitable memory blocks. Fail the request. */
     spin_unlock(&heap_lock);
     return NULL;
diff -r dd0cdf8346df -r 9a3efacb9e39 xen/include/public/memory.h
--- a/xen/include/public/memory.h	Tue Mar 30 18:03:27 2010 -0400
+++ b/xen/include/public/memory.h	Tue Mar 30 18:51:31 2010 -0400
@@ -52,6 +52,8 @@
 #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)
+#define XENMEMF_exact_node_request  (1 << 17)
+#define XENMEMF_exact_node(n) (XENMEMF_node(n) | XENMEMF_exact_node_request)
 #endif
 
 struct xen_memory_reservation {
diff -r dd0cdf8346df -r 9a3efacb9e39 xen/include/xen/mm.h
--- a/xen/include/xen/mm.h	Tue Mar 30 18:03:27 2010 -0400
+++ b/xen/include/xen/mm.h	Tue Mar 30 18:51:31 2010 -0400
@@ -80,6 +80,8 @@
 #define  MEMF_populate_on_demand (1U<<_MEMF_populate_on_demand)
 #define _MEMF_tmem        2
 #define  MEMF_tmem        (1U<<_MEMF_tmem)
+#define _MEMF_exact_node  3
+#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

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-07 11:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-04 19:30 [PATCH 02/11] [XEN] exact node request Dulloor
2010-04-07 11:51 ` Andre Przywara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).