# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1278315626 -3600
# Node ID 9d965ac1b0dbcb2f1fd4845e30753251d68d064f
# Parent 34f612ed41842c6e1c84745a8578b06da531cfe3
Add an exact-node request flag for mem allocations.
Signed-off-by : Dulloor <dulloor@xxxxxxxxx>
---
xen/common/memory.c | 2 ++
xen/common/page_alloc.c | 8 ++++++++
xen/include/public/memory.h | 3 +++
xen/include/xen/mm.h | 2 ++
4 files changed, 15 insertions(+)
diff -r 34f612ed4184 -r 9d965ac1b0db xen/common/memory.c
--- a/xen/common/memory.c Mon Jul 05 08:31:29 2010 +0100
+++ b/xen/common/memory.c Mon Jul 05 08:40:26 2010 +0100
@@ -545,6 +545,8 @@ long do_memory_op(unsigned long cmd, XEN
}
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 34f612ed4184 -r 9d965ac1b0db xen/common/page_alloc.c
--- a/xen/common/page_alloc.c Mon Jul 05 08:31:29 2010 +0100
+++ b/xen/common/page_alloc.c Mon Jul 05 08:40:26 2010 +0100
@@ -300,11 +300,15 @@ static struct page_info *alloc_heap_page
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_page
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_page
return pg;
}
+ not_found:
/* No suitable memory blocks. Fail the request. */
spin_unlock(&heap_lock);
return NULL;
diff -r 34f612ed4184 -r 9d965ac1b0db xen/include/public/memory.h
--- a/xen/include/public/memory.h Mon Jul 05 08:31:29 2010 +0100
+++ b/xen/include/public/memory.h Mon Jul 05 08:40:26 2010 +0100
@@ -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 {
diff -r 34f612ed4184 -r 9d965ac1b0db xen/include/xen/mm.h
--- a/xen/include/xen/mm.h Mon Jul 05 08:31:29 2010 +0100
+++ b/xen/include/xen/mm.h Mon Jul 05 08:40:26 2010 +0100
@@ -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
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|