Skip to contentSkip to conversation

NUMA memory allocation strategies

PATCH In review Dulloor 1 participant 1 message Apr 4, 2010

lore
Share & tools
lore

Dulloor

author
#0 lore raw

PATCH 4/11 NUMA memory allocation strategies

The patch implements the CONFINE/STRIPE/SPLIT NUMA allocation strategies :

- CONFINE : Confine the VM memory allocation to a single node. As opposed to the current method of doing this in python, the patch implements this in libxc(along with other strategies) and with assurance that the memory actually comes from the selected node.
- STRIPE : If the VM memory doesn't fit in a single node and if the VM is not compiled with guest-numa-support, the memory is allocated striped across a selected max-set of nodes.
- SPLIT : If the VM memory doesn't fit in a single node and if the VM is compiled with guest-numa-support, the memory is allocated split (equally for now) from the min-set of nodes. The VM is then made aware of this NUMA allocation (virtual NUMA enlightenment).

-dulloor

tools/libxc/Makefile +1 -0
diff -r c636287eab3c -r d6b7abf0d2d5 tools/libxc/Makefile
@@ -25,6 +25,7 @@
 CTRL_SRCS-y       += xc_mem_event.c
 CTRL_SRCS-y       += xc_mem_paging.c
 CTRL_SRCS-y       += xc_memshr.c
+CTRL_SRCS-y       += xc_dom_numa.c
 CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c
 CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c
 CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c
tools/libxc/xc_dom.h +2 -0
diff -r c636287eab3c -r d6b7abf0d2d5 tools/libxc/xc_dom.h
@@ -1,4 +1,5 @@
 #include <xen/libelf/libelf.h>
+#include <xen/memory.h>
 
 #define INVALID_P2M_ENTRY   ((xen_pfn_t)-1)
 
@@ -102,6 +103,7 @@
     int xen_version;
     xen_capabilities_info_t xen_caps;
 
+    struct xen_domain_numa_layout *numa_layout;
     /* kernel loader, arch hooks */
     struct xc_dom_loader *kernel_loader;
     void *private_loader;
tools/libxc/xc_dom_core.c +8 -2
diff -r c636287eab3c -r d6b7abf0d2d5 tools/libxc/xc_dom_core.c
@@ -19,6 +19,7 @@
 
 #include "xg_private.h"
 #include "xc_dom.h"
+#include "xc_dom_numa.h"
 
 /* ------------------------------------------------------------------------ */
 /* debugging                                                                */
@@ -678,8 +679,13 @@
                   __FUNCTION__, mem_mb, nr_pages, 1 << (page_shift-10));
     dom->total_pages = nr_pages;
 
-    xc_dom_printf("%s: 0x%" PRIpfn " pages\n",
-                  __FUNCTION__, dom->total_pages);
+    xc_dom_printf("%s: 0x%" PRIpfn " pages\n", __FUNCTION__, dom->total_pages);
+
+    if (xc_setup_domain_numa_layout(dom))
+    {
+        /* Ignore the error and proceed as non-numa guest */
+        xc_dom_printf("%s: xc_setup_domain_layout failed\n", __FUNCTION__);
+    }
 
     return 0;
 }
tools/libxc/xc_dom_numa.c new file +512 -0

512 lines not on this page · raw message

tools/libxc/xc_dom_numa.h new file +21 -0
diff -r c636287eab3c -r d6b7abf0d2d5 tools/libxc/xc_dom_numa.h
@@ -0,0 +1,21 @@
+#ifndef __XC_DOM_NUMA_H
+#define __XC_DOM_NUMA_H
+
+#define XC_MAX_NODES 8
+
+struct xc_machine_numa_layout {
+    uint64_t memsize;
+    uint64_t memfree;
+
+    uint32_t max_nodes;
+    uint32_t node_distance[XC_MAX_NODES*XC_MAX_NODES];
+    struct xenmem_node_data node_data[XC_MAX_NODES];
+};
+typedef struct xc_machine_numa_layout xc_machine_numa_layout_t;
+typedef struct xen_domain_numa_layout xc_domain_numa_layout_t;
+
+extern int xc_setup_domain_numa_layout(struct xc_dom_image *dom);
+extern int xc_domain_nodemem_distribution(struct xc_dom_image *dom);
+extern void dump_guest_numa_layout(struct xc_dom_image *dom,
+                                        xc_domain_numa_layout_t *layout);
+#endif

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel