Skip to contentSkip to conversation

vnuma hook to debug-keys u

PATCH Superseded Elena Ufimtseva 3 participants 14 messages Aug 26, 2014 – Aug 27, 2014

v8 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

PATCH v8 3/9 vnuma hook to debug-keys u

Add debug-keys hook to display vnuma topology.

---
 xen/arch/x86/numa.c |   35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)
xen/arch/x86/numa.c +34 -1
index b141877..9efceac 100644
@@ -347,7 +347,7 @@ EXPORT_SYMBOL(node_data);
 static void dump_numa(unsigned char key)
 {
 	s_time_t now = NOW();
-	int i;
+	int i, j, n, err;
 	struct domain *d;
 	struct page_info *page;
 	unsigned int page_num_node[MAX_NUMNODES];
@@ -389,6 +389,39 @@ static void dump_numa(unsigned char key)
 
 		for_each_online_node(i)
 			printk("    Node %u: %u\n", i, page_num_node[i]);
+
+		if ( d->vnuma )
+		{
+			printk("    Domain has %u vnodes, %u vcpus\n",
+				   d->vnuma->nr_vnodes, d->max_vcpus);
+			for ( i = 0; i < d->vnuma->nr_vnodes; i++ )
+			{
+				err = snprintf(keyhandler_scratch, 12, "%u",
+						       d->vnuma->vnode_to_pnode[i]);
+				if ( err < 0 || d->vnuma->vnode_to_pnode[i] == NUMA_NO_NODE )
+					snprintf(keyhandler_scratch, 3, "???");
+				printk("        vnode %3u - pnode %s,", i, keyhandler_scratch);
+
+				printk(" %"PRIu64" MB, ",
+					   (d->vnuma->vmemrange[i].end - d->vnuma->vmemrange[i].start) >> 20);
+
+				printk("vcpu nrs: ");
+				for ( j = 0, n = 0; j < d->max_vcpus; j++ )
+				{
+					if ( d->vnuma->vcpu_to_vnode[j] == i )
+					{
+						if ( ((n + 1) % 8) == 0 )
+							printk("%d\n", j);
+						else if ( !(n % 8) && n != 0 )
+							printk("%s%d ", "             ", j);
+						else
+							printk("%d ", j);
+						n++;
+					}
+				}
+				printk("\n");
+			}
+		}
 	}
 
 	rcu_read_unlock(&domlist_read_lock);
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v8 4/9 libxc: Introduce xc_domain_setvnuma to set vNUMA

With the introduction of the XEN_DOMCTL_setvnumainfo in patch titled: "xen: vnuma topology and subop hypercalls" we put in the plumbing here to use from the toolstack. The user is allowed to call this multiple times if they wish so. It will error out if the nr_vnodes or nr_vcpus is zero.

---
 tools/libxc/xc_domain.c |   65 +++++++++++++++++++++++++++++++++++++++++++++++
 tools/libxc/xenctrl.h   |   10 ++++++++
 2 files changed, 75 insertions(+)
tools/libxc/xc_domain.c +65 -0
index c67ac9a..1708766 100644
@@ -2124,6 +2124,71 @@ int xc_domain_set_max_evtchn(xc_interface *xch, uint32_t domid,
     return do_domctl(xch, &domctl);
 }
 
+/* Plumbing Xen with vNUMA topology */
+int xc_domain_setvnuma(xc_interface *xch,
+                       uint32_t domid,
+                       uint32_t nr_vnodes,
+                       uint32_t nr_regions,
+                       uint32_t nr_vcpus,
+                       vmemrange_t *vmemrange,
+                       unsigned int *vdistance,
+                       unsigned int *vcpu_to_vnode,
+                       unsigned int *vnode_to_pnode)
+{
+    int rc;
+    DECLARE_DOMCTL;
+    DECLARE_HYPERCALL_BOUNCE(vmemrange, sizeof(*vmemrange) * nr_regions,
+                             XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+    DECLARE_HYPERCALL_BOUNCE(vdistance, sizeof(*vdistance) *
+                             nr_vnodes * nr_vnodes,
+                             XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+    DECLARE_HYPERCALL_BOUNCE(vcpu_to_vnode, sizeof(*vcpu_to_vnode) * nr_vcpus,
+                             XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+    DECLARE_HYPERCALL_BOUNCE(vnode_to_pnode, sizeof(*vnode_to_pnode) *
+                             nr_vnodes,
+                             XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+    errno = EINVAL;
+
+    if ( nr_vnodes == 0 || nr_regions == 0 || nr_regions < nr_vnodes )
+        return -1;
+
+    if ( !vdistance || !vcpu_to_vnode || !vmemrange || !vnode_to_pnode )
+    {
+        PERROR("%s: Cant set vnuma without initializing topology", __func__);
+        return -1;
+    }
+
+    if ( xc_hypercall_bounce_pre(xch, vmemrange)      ||
+         xc_hypercall_bounce_pre(xch, vdistance)      ||
+         xc_hypercall_bounce_pre(xch, vcpu_to_vnode)  ||
+         xc_hypercall_bounce_pre(xch, vnode_to_pnode) )
+    {
+        rc = -1;
+        goto vnumaset_fail;
+
+    }
+
+    set_xen_guest_handle(domctl.u.vnuma.vmemrange, vmemrange);
+    set_xen_guest_handle(domctl.u.vnuma.vdistance, vdistance);
+    set_xen_guest_handle(domctl.u.vnuma.vcpu_to_vnode, vcpu_to_vnode);
+    set_xen_guest_handle(domctl.u.vnuma.vnode_to_pnode, vnode_to_pnode);
+
+    domctl.cmd = XEN_DOMCTL_setvnumainfo;
+    domctl.domain = (domid_t)domid;
+    domctl.u.vnuma.nr_vnodes = nr_vnodes;
+    domctl.u.vnuma.nr_regions = nr_regions;
+
+    rc = do_domctl(xch, &domctl);
+
+ vnumaset_fail:
+    xc_hypercall_bounce_post(xch, vmemrange);
+    xc_hypercall_bounce_post(xch, vdistance);
+    xc_hypercall_bounce_post(xch, vcpu_to_vnode);
+    xc_hypercall_bounce_post(xch, vnode_to_pnode);
+
+    return rc;
+}
+
 /*
  * Local variables:
  * mode: C
tools/libxc/xenctrl.h +10 -0
index 1c5d0db..1c8aa42 100644
@@ -1245,6 +1245,16 @@ int xc_domain_set_memmap_limit(xc_interface *xch,
                                uint32_t domid,
                                unsigned long map_limitkb);
 
+int xc_domain_setvnuma(xc_interface *xch,
+                        uint32_t domid,
+                        uint32_t nr_vnodes,
+                        uint32_t nr_regions,
+                        uint32_t nr_vcpus,
+                        vmemrange_t *vmemrange,
+                        unsigned int *vdistance,
+                        unsigned int *vcpu_to_vnode,
+                        unsigned int *vnode_to_pnode);
+
 #if defined(__i386__) || defined(__x86_64__)
 /*
  * PC BIOS standard E820 types and structure.
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH v8 5/9 libxl: vnuma types declararion

In reply to Elena Ufimtseva

Adds vnuma topology types declarations to libxl_domain_build_info structure.

---
 tools/libxl/libxl_types.idl |    8 +++++++-
 tools/libxl/libxl_vnuma.h   |   16 ++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 tools/libxl/libxl_vnuma.h
tools/libxl/libxl_types.idl +7 -1
index 0b3496f..ed48b80 100644
@@ -333,7 +333,13 @@ libxl_domain_build_info = Struct("domain_build_info",[
     ("disable_migrate", libxl_defbool),
     ("cpuid",           libxl_cpuid_policy_list),
     ("blkdev_start",    string),
-    
+    ("vnodes",          uint32),
+    ("vregions",        uint32),
+    ("vnuma_mem",       Array(uint64, "num_vnuma_mem")),
+    ("vnuma_vcpumap",   Array(uint32, "num_vnuma_vcpumap")),
+    ("vdistance",       Array(uint32, "num_vdistance")),
+    ("vnuma_vnodemap",  Array(uint32, "num_vnuma_vnondemap")),
+    ("vnuma_autoplacement",  libxl_defbool),
     ("device_model_version", libxl_device_model_version),
     ("device_model_stubdomain", libxl_defbool),
     # if you set device_model you must set device_model_version too
tools/libxl/libxl_vnuma.h new file +16 -0
new file mode 100644
index 0000000..2ec46db
@@ -0,0 +1,16 @@
+#ifndef LIBXL_VNUMA_H
+#define LIBXL_VNUMA_H
+
+#include "libxl_osdeps.h" /* must come before any other headers */
+
+#define VNUMA_NO_NODE ~((unsigned int)0)
+
+/*
+ * Min vNUMA node size from Linux for x86 architecture.
+ * See linux source code arch/x86/include/asm/numa.h
+ */
+#define MIN_VNODE_SIZE  (4*1024*1024)
+
+#define MAX_VNUMA_NODES ((unsigned int)1 << 10)
+
+#endif
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH v8 6/9 libxl: build numa nodes memory blocks

In reply to Elena Ufimtseva

Create the vmemrange structure based on the PV guests E820 map. Values are in in Megabytes. Also export the E820 filter code e820_sanitize out to be available internally.

---
 tools/libxl/libxl_internal.h |    9 ++
 tools/libxl/libxl_numa.c     |  201 ++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_x86.c      |    3 +-
 3 files changed, 212 insertions(+), 1 deletion(-)
tools/libxl/libxl_internal.h +9 -0
index beb052e..63ccb5e 100644
@@ -3088,6 +3088,15 @@ void libxl__numa_candidate_put_nodemap(libxl__gc *gc,
     libxl_bitmap_copy(CTX, &cndt->nodemap, nodemap);
 }
 
+bool libxl__vnodemap_is_usable(libxl__gc *gc, libxl_domain_build_info *info);
+
+int e820_sanitize(libxl_ctx *ctx, struct e820entry src[], uint32_t *nr_entries,
+                  unsigned long map_limitkb, unsigned long balloon_kb);
+
+int libxl__vnuma_align_mem(libxl__gc *gc, uint32_t domid,
+                           struct libxl_domain_build_info *b_info,
+                           vmemrange_t *memblks);
+
 _hidden int libxl__ms_vm_genid_set(libxl__gc *gc, uint32_t domid,
                                    const libxl_ms_vm_genid *id);
 
tools/libxl/libxl_numa.c +201 -0

213 lines not on this page · raw message

tools/libxl/libxl_x86.c +2 -1
index 7589060..46e84e4 100644
@@ -1,5 +1,6 @@
 #include "libxl_internal.h"
 #include "libxl_arch.h"
+#include "libxl_vnuma.h"
 
 static const char *e820_names(int type)
 {
@@ -14,7 +15,7 @@ static const char *e820_names(int type)
     return "Unknown";
 }
 
-static int e820_sanitize(libxl_ctx *ctx, struct e820entry src[],
+int e820_sanitize(libxl_ctx *ctx, struct e820entry src[],
                          uint32_t *nr_entries,
                          unsigned long map_limitkb,
                          unsigned long balloon_kb)
Signature · 1 line
1.7.10.4
#5 lore raw

PATCH v8 7/9 libxc: allocate domain memory for vnuma enabled

In reply to Elena Ufimtseva

vNUMA-aware domain memory allocation based on provided vnode to pnode map. If this map is not defined, use default allocation. Default allocation will not specify any physical node when allocating memory.
Domain creation will fail if at least one node was not defined.

---
 tools/libxc/xc_dom.h     |   13 ++++++++
 tools/libxc/xc_dom_x86.c |   76 ++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 77 insertions(+), 12 deletions(-)
tools/libxc/xc_dom.h +13 -0
index 6ae6a9f..61c2a06 100644
@@ -164,6 +164,16 @@ struct xc_dom_image {
 
     /* kernel loader */
     struct xc_dom_arch *arch_hooks;
+
+   /*
+    * vNUMA topology and memory allocation structure.
+    * Defines the way to allocate memory on per NUMA
+    * physical defined by vnode_to_pnode.
+    */
+    uint32_t vnodes;
+    uint64_t *numa_memszs;
+    unsigned int *vnode_to_pnode;
+
     /* allocate up to virt_alloc_end */
     int (*allocate) (struct xc_dom_image * dom, xen_vaddr_t up_to);
 };
@@ -385,6 +395,9 @@ static inline xen_pfn_t xc_dom_p2m_guest(struct xc_dom_image *dom,
 int arch_setup_meminit(struct xc_dom_image *dom);
 int arch_setup_bootearly(struct xc_dom_image *dom);
 int arch_setup_bootlate(struct xc_dom_image *dom);
+int arch_boot_alloc(struct xc_dom_image *dom);
+
+#define LIBXC_VNUMA_NO_NODE ~((unsigned int)0)
 
 /*
  * Local variables:
tools/libxc/xc_dom_x86.c +64 -12

96 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#6 lore raw

PATCH v8 8/9 libxl: vnuma nodes placement bits

In reply to Elena Ufimtseva

Automatic numa placement cancels manual vnode placement mechanism. If numa placement explicitly specified, try to fit vnodes to the physical nodes.

---
 tools/libxl/libxl_create.c |    1 +
 tools/libxl/libxl_dom.c    |  204 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 205 insertions(+)
tools/libxl/libxl_create.c +1 -0
index 9b66294..19023cf 100644
@@ -203,6 +203,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
     }
 
     libxl_defbool_setdefault(&b_info->numa_placement, true);
+    libxl_defbool_setdefault(&b_info->vnuma_autoplacement, true);
 
     if (b_info->max_memkb == LIBXL_MEMKB_DEFAULT)
         b_info->max_memkb = 32 * 1024;
tools/libxl/libxl_dom.c +204 -0

253 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#7 lore raw

PATCH v8 9/9 libxl: vnuma topology configuration parser and doc

In reply to Elena Ufimtseva

Parses vnuma topoplogy number of nodes and memory ranges. If not defined, initializes vnuma with only one node and default topology. This one node covers all domain memory and all vcpus assigned to it.

---
 docs/man/xl.cfg.pod.5    |   77 ++++++++
 tools/libxl/xl_cmdimpl.c |  434 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 511 insertions(+)
docs/man/xl.cfg.pod.5 +77 -0
index 1e04eed..073664e 100644
@@ -264,6 +264,83 @@ if the values of B<memory=> and B<maxmem=> differ.
 A "pre-ballooned" HVM guest needs a balloon driver, without a balloon driver
 it will crash.
 
+=item B<vnuma_nodes=N>
+
+Number of vNUMA nodes the guest will be initialized with on boot.
+PV guest by default will have one vnuma node.
+
+=item B<vnuma_mem=[vmem1, vmem2, ...]>
+
+List of memory sizes for each node, defined in MBytes. Number of items listed must
+match nr_vnodes. If the sum of all vnode memories does not match the domain memory
+or there are missing nodes, it will fail.
+If not specified, memory will be equally split between vnodes. Current minimum
+memory size for one node is limited by 32MB.
+
+Example: vnuma_mem=[1024, 1024, 2048, 2048]
+Total amount of memory in guest: 6GB
+
+=item B<vdistance=[d1, d2]>
+
+Defines the distance table for vNUMA nodes. NUMA topology distances are
+represented by two dimensional square matrix. One element of it [i,j] is
+a distance between nodes i and j. Trivial case is where all diagonal elements
+are equal and matrix is symmetrical. vdistance configuration option allows
+to define two values d1 and d2. d1 will be used for all diagonal elements of
+distance matrix. All other values will be equal to d2 value. Usually distances
+are multiple of 10 in Linux and same rule used here.
+If not specified, the default constants values will be used for distance,
+e.g. [10, 20]. For one node default distance is [10];
+
+Examples:
+vnodes = 3
+vdistance=[10, 20]
+will create this distance table (this is default setting as well):
+[10, 20, 20]
+[20, 10, 20]
+[20, 20, 10]
+
+=item B<vnuma_vcpumap=[node_nr, node_nr, ...]>
+
+Defines vcpu to vnode mapping as a list of integers. The position in the list
+is a vcpu number, and the value is the vnode number to which the vcpu will be
+assigned to.
+Current limitations:
+- vNUMA node must have at least one vcpu, otherwise default vcpu_to_vnode will be used.
+- Total number of vnodes cannot be bigger then number of vcpus.
+
+Example:
+Map of 4 vcpus to 2 vnodes:
+0,1 vcpu -> vnode0
+2,3 vcpu -> vnode1:
+
+vnuma_vcpumap = [0, 0, 1, 1]
+ 4 vcpus here -  0  1  2  3
+
+=item B<vnuma_vnodemap=[p1, p2, ..., pn]>
+
+List of physical node numbers, position in the list represents vnode number.
+Used for manual placement of vnuma nodes to physical NUMA nodes.
+Will not be used if automatic numa placement is active.
+
+Example:
+assume NUMA machine with 4 physical nodes. Placing vnuma node 0 to pnode 2,
+vnuma node 1 to pnode 3:
+vnode0 -> pnode2
+vnode1 -> pnode3
+
+vnuma_vnodemap=[2, 3]
+first vnode will be placed on node 2, second on node 3.
+
+=item B<vnuma_autoplacement=[0|1]>
+
+If set to 1 and automatic NUMA placement is enabled, automatically will find the best
+physical node to place vnuma nodes on. vnuma_vnodemap will be ignored. Automatic NUMA
+placement is enabled if domain has no pinned cpus.
+If vnuma_autoplacement is set to 0, then the vnodes will be placed on NUMA nodes set
+in vnuma_vnodemap if there is enough memory on physical nodes. If not, then the allocation
+will be made on any of the available node and be placed on multiple physical NUMA nodes.
+
 =back
 
 =head3 Event Actions
tools/libxl/xl_cmdimpl.c +434 -0

452 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#8 lore raw
In reply to Elena Ufimtseva
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 26.08.14 at 09:45, <[email protected]> wrote:
xen/arch/x86/numa.c +26 -0
@@ -389,6 +389,39 @@ static void dump_numa(unsigned char key)
 
 		for_each_online_node(i)
 			printk("    Node %u: %u\n", i, page_num_node[i]);
+
+		if ( d->vnuma )
+		{
+			printk("    Domain has %u vnodes, %u vcpus\n",
+				   d->vnuma->nr_vnodes, d->max_vcpus);
+			for ( i = 0; i < d->vnuma->nr_vnodes; i++ )
+			{
+				err = snprintf(keyhandler_scratch, 12, "%u",
+						       d->vnuma->vnode_to_pnode[i]);
+				if ( err < 0 || d->vnuma->vnode_to_pnode[i] == NUMA_NO_NODE )
+					snprintf(keyhandler_scratch, 3, "???");
+				printk("        vnode %3u - pnode %s,", i, keyhandler_scratch);
+
+				printk(" %"PRIu64" MB, ",
+					   (d->vnuma->vmemrange[i].end - d->vnuma->vmemrange[i].start) >> 20);
+
+				printk("vcpu nrs: ");
+				for ( j = 0, n = 0; j < d->max_vcpus; j++ )
+				{
+					if ( d->vnuma->vcpu_to_vnode[j] == i )
+					{
+						if ( ((n + 1) % 8) == 0 )
+							printk("%d\n", j);
+						else if ( !(n % 8) && n != 0 )
+							printk("%s%d ", "             ", j);
+						else

xen/arch/x86/numa.c static void dump_numa(unsigned char key) · line 427

Quoted 10 lines
xen/arch/x86/numa.c +7 -0
+							printk("%d ", j);
+						n++;
+					}
+				}
+				printk("\n");
+			}
+		}
 	}
 
 	rcu_read_unlock(&domlist_read_lock);

Actually I'm afraid Konrad's comment (and me agreeing to it) misguided you here: The function is currently written in Linux style, so Linux style is what the changes should be in. I.e. opening curly braces on the same line as the end of their control construct, and no blanks inside outermost parentheses of control constructs.

However, the comment regarding overly long lines was correct (and sadly still stands), and there are indentation issues too.

Jan

#9 lore raw
Quoted 49 lines · Jan Beulich
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 26.08.14 at 09:45, <[email protected]> wrote:
xen/arch/x86/numa.c +26 -0
@@ -389,6 +389,39 @@ static void dump_numa(unsigned char key)
 
              for_each_online_node(i)
                      printk("    Node %u: %u\n", i, page_num_node[i]);
+
+             if ( d->vnuma )
+             {
+                     printk("    Domain has %u vnodes, %u vcpus\n",
+                                d->vnuma->nr_vnodes, d->max_vcpus);
+                     for ( i = 0; i < d->vnuma->nr_vnodes; i++ )
+                     {
+                             err = snprintf(keyhandler_scratch, 12, "%u",
+                                                    d->vnuma->vnode_to_pnode[i]);
+                             if ( err < 0 || d->vnuma->vnode_to_pnode[i] == NUMA_NO_NODE )
+                                     snprintf(keyhandler_scratch, 3, "???");
+                             printk("        vnode %3u - pnode %s,", i, keyhandler_scratch);
+
+                             printk(" %"PRIu64" MB, ",
+                                        (d->vnuma->vmemrange[i].end - d->vnuma->vmemrange[i].start) >> 20);
+
+                             printk("vcpu nrs: ");
+                             for ( j = 0, n = 0; j < d->max_vcpus; j++ )
+                             {
+                                     if ( d->vnuma->vcpu_to_vnode[j] == i )
+                                     {
+                                             if ( ((n + 1) % 8) == 0 )
+                                                     printk("%d\n", j);
+                                             else if ( !(n % 8) && n != 0 )
+                                                     printk("%s%d ", "             ", j);
+                                             else

xen/arch/x86/numa.c static void dump_numa(unsigned char key) · line 427

Quoted 10 lines
xen/arch/x86/numa.c +7 -0
+                                                     printk("%d ", j);
+                                             n++;
+                                     }
+                             }
+                             printk("\n");
+                     }
+             }
      }
 
      rcu_read_unlock(&domlist_read_lock);

Actually I'm afraid Konrad's comment (and me agreeing to it) misguided you here: The function is currently written in Linux style, so Linux style is what the changes should be in. I.e. opening curly braces on the same line as the end of their control construct, and no blanks inside outermost parentheses of control constructs.

Quoted 5 lines

However, the comment regarding overly long lines was correct (and sadly still stands), and there are indentation issues too.

Jan

Hi Jan

This file has both coding styles and every my attempt to match it fails :)

Can I make changes to numa.c so it will be formatted like any other file if there
is no reason to have it formatted in this way?
Also the indentation symbols are different there as well. Re-formatting it will help me tremendously and maybe others as well.

Signature · 1 line
Elena
#10 lore raw
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 26.08.14 at 17:36, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich

Actually I'm afraid Konrad's comment (and me agreeing to it) misguided you here: The function is currently written in Linux style, so Linux style is what the changes should be in. I.e. opening curly braces on the same line as the end of their control construct, and no blanks inside outermost parentheses of control constructs.

Quoted 4 lines
Quoted 2 lines

However, the comment regarding overly long lines was correct (and sadly still stands), and there are indentation issues too.

This file has both coding styles and every my attempt to match it fails :)

Not really, its Linux style with perhaps a few mistakes.

Quoted 3 lines

Can I make changes to numa.c so it will be formatted like any other file if there
is no reason to have it formatted in this way?

If you feel up to making it have entirely uniform style, just go for it.

Jan

#11 lore raw
Quoted 14 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 26.08.14 at 17:36, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich

Actually I'm afraid Konrad's comment (and me agreeing to it) misguided you here: The function is currently written in Linux style, so Linux style is what the changes should be in. I.e. opening curly braces on the same line as the end of their control construct, and no blanks inside outermost parentheses of control constructs.

Quoted 4 lines
Quoted 2 lines

However, the comment regarding overly long lines was correct (and sadly still stands), and there are indentation issues too.

This file has both coding styles and every my attempt to match it fails :)

Quoted 7 lines

Not really, its Linux style with perhaps a few mistakes.

Quoted 3 lines

Can I make changes to numa.c so it will be formatted like any other file if there
is no reason to have it formatted in this way?

If you feel up to making it have entirely uniform style, just go for it.

Yes, Id prefer this.

Thank you Jan.

Quoted 3 lines

Jan

Signature · 1 line
Elena
#12 lore raw
In reply to Elena Ufimtseva
Quoted 3 lines · Elena Ufimtseva

Add debug-keys hook to display vnuma topology.

Now that I had led you astray on the style (truly sorry and I am really happy Jan spotted it), when that gets fixed to be right type you can add 'Reviewed-by: Konrad Rzeszutek Wilk <[email protected]>'.

Or if there is not enough time, there could be a cleanup patch to fix those style guide later on.

Quoted 60 lines
---
 xen/arch/x86/numa.c |   35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)
xen/arch/x86/numa.c +34 -1
index b141877..9efceac 100644
@@ -347,7 +347,7 @@ EXPORT_SYMBOL(node_data);
 static void dump_numa(unsigned char key)
 {
 	s_time_t now = NOW();
-	int i;
+	int i, j, n, err;
 	struct domain *d;
 	struct page_info *page;
 	unsigned int page_num_node[MAX_NUMNODES];
@@ -389,6 +389,39 @@ static void dump_numa(unsigned char key)
 
 		for_each_online_node(i)
 			printk("    Node %u: %u\n", i, page_num_node[i]);
+
+		if ( d->vnuma )
+		{
+			printk("    Domain has %u vnodes, %u vcpus\n",
+				   d->vnuma->nr_vnodes, d->max_vcpus);
+			for ( i = 0; i < d->vnuma->nr_vnodes; i++ )
+			{
+				err = snprintf(keyhandler_scratch, 12, "%u",
+						       d->vnuma->vnode_to_pnode[i]);
+				if ( err < 0 || d->vnuma->vnode_to_pnode[i] == NUMA_NO_NODE )
+					snprintf(keyhandler_scratch, 3, "???");
+				printk("        vnode %3u - pnode %s,", i, keyhandler_scratch);
+
+				printk(" %"PRIu64" MB, ",
+					   (d->vnuma->vmemrange[i].end - d->vnuma->vmemrange[i].start) >> 20);
+
+				printk("vcpu nrs: ");
+				for ( j = 0, n = 0; j < d->max_vcpus; j++ )
+				{
+					if ( d->vnuma->vcpu_to_vnode[j] == i )
+					{
+						if ( ((n + 1) % 8) == 0 )
+							printk("%d\n", j);
+						else if ( !(n % 8) && n != 0 )
+							printk("%s%d ", "             ", j);
+						else
+							printk("%d ", j);
+						n++;
+					}
+				}
+				printk("\n");
+			}
+		}
 	}
 
 	rcu_read_unlock(&domlist_read_lock);
Signature · 1 line
1.7.10.4
Reviewed-by on v8 4/9
#2 lore raw

Re: [PATCH v8 4/9] libxc: Introduce xc_domain_setvnuma to set vNUMA

In reply to Elena Ufimtseva
Quoted 7 lines · Elena Ufimtseva

With the introduction of the XEN_DOMCTL_setvnumainfo in patch titled: "xen: vnuma topology and subop hypercalls" we put in the plumbing here to use from the toolstack. The user is allowed to call this multiple times if they wish so. It will error out if the nr_vnodes or nr_vcpus is zero.

Quoted 105 lines
---
 tools/libxc/xc_domain.c |   65 +++++++++++++++++++++++++++++++++++++++++++++++
 tools/libxc/xenctrl.h   |   10 ++++++++
 2 files changed, 75 insertions(+)
tools/libxc/xc_domain.c +65 -0
index c67ac9a..1708766 100644
@@ -2124,6 +2124,71 @@ int xc_domain_set_max_evtchn(xc_interface *xch, uint32_t domid,
     return do_domctl(xch, &domctl);
 }
 
+/* Plumbing Xen with vNUMA topology */
+int xc_domain_setvnuma(xc_interface *xch,
+                       uint32_t domid,
+                       uint32_t nr_vnodes,
+                       uint32_t nr_regions,
+                       uint32_t nr_vcpus,
+                       vmemrange_t *vmemrange,
+                       unsigned int *vdistance,
+                       unsigned int *vcpu_to_vnode,
+                       unsigned int *vnode_to_pnode)
+{
+    int rc;
+    DECLARE_DOMCTL;
+    DECLARE_HYPERCALL_BOUNCE(vmemrange, sizeof(*vmemrange) * nr_regions,
+                             XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+    DECLARE_HYPERCALL_BOUNCE(vdistance, sizeof(*vdistance) *
+                             nr_vnodes * nr_vnodes,
+                             XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+    DECLARE_HYPERCALL_BOUNCE(vcpu_to_vnode, sizeof(*vcpu_to_vnode) * nr_vcpus,
+                             XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+    DECLARE_HYPERCALL_BOUNCE(vnode_to_pnode, sizeof(*vnode_to_pnode) *
+                             nr_vnodes,
+                             XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+    errno = EINVAL;
+
+    if ( nr_vnodes == 0 || nr_regions == 0 || nr_regions < nr_vnodes )
+        return -1;
+
+    if ( !vdistance || !vcpu_to_vnode || !vmemrange || !vnode_to_pnode )
+    {
+        PERROR("%s: Cant set vnuma without initializing topology", __func__);
+        return -1;
+    }
+
+    if ( xc_hypercall_bounce_pre(xch, vmemrange)      ||
+         xc_hypercall_bounce_pre(xch, vdistance)      ||
+         xc_hypercall_bounce_pre(xch, vcpu_to_vnode)  ||
+         xc_hypercall_bounce_pre(xch, vnode_to_pnode) )
+    {
+        rc = -1;
+        goto vnumaset_fail;
+
+    }
+
+    set_xen_guest_handle(domctl.u.vnuma.vmemrange, vmemrange);
+    set_xen_guest_handle(domctl.u.vnuma.vdistance, vdistance);
+    set_xen_guest_handle(domctl.u.vnuma.vcpu_to_vnode, vcpu_to_vnode);
+    set_xen_guest_handle(domctl.u.vnuma.vnode_to_pnode, vnode_to_pnode);
+
+    domctl.cmd = XEN_DOMCTL_setvnumainfo;
+    domctl.domain = (domid_t)domid;
+    domctl.u.vnuma.nr_vnodes = nr_vnodes;
+    domctl.u.vnuma.nr_regions = nr_regions;
+
+    rc = do_domctl(xch, &domctl);
+
+ vnumaset_fail:
+    xc_hypercall_bounce_post(xch, vmemrange);
+    xc_hypercall_bounce_post(xch, vdistance);
+    xc_hypercall_bounce_post(xch, vcpu_to_vnode);
+    xc_hypercall_bounce_post(xch, vnode_to_pnode);
+
+    return rc;
+}
+
 /*
  * Local variables:
  * mode: C
tools/libxc/xenctrl.h +10 -0
index 1c5d0db..1c8aa42 100644
@@ -1245,6 +1245,16 @@ int xc_domain_set_memmap_limit(xc_interface *xch,
                                uint32_t domid,
                                unsigned long map_limitkb);
 
+int xc_domain_setvnuma(xc_interface *xch,
+                        uint32_t domid,
+                        uint32_t nr_vnodes,
+                        uint32_t nr_regions,
+                        uint32_t nr_vcpus,
+                        vmemrange_t *vmemrange,
+                        unsigned int *vdistance,
+                        unsigned int *vcpu_to_vnode,
+                        unsigned int *vnode_to_pnode);
+
 #if defined(__i386__) || defined(__x86_64__)
 /*
  * PC BIOS standard E820 types and structure.
Signature · 1 line
1.7.10.4
#13 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 69 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Elena Ufimtseva

Add debug-keys hook to display vnuma topology.

Now that I had led you astray on the style (truly sorry and I am really happy Jan spotted it), when that gets fixed to be right type you can add 'Reviewed-by: Konrad Rzeszutek Wilk <[email protected]>'.

Or if there is not enough time, there could be a cleanup patch to fix those style guide later on.

Quoted 56 lines
---
 xen/arch/x86/numa.c |   35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)
xen/arch/x86/numa.c +34 -1
index b141877..9efceac 100644
@@ -347,7 +347,7 @@ EXPORT_SYMBOL(node_data);
 static void dump_numa(unsigned char key)
 {
      s_time_t now = NOW();
-     int i;
+     int i, j, n, err;
      struct domain *d;
      struct page_info *page;
      unsigned int page_num_node[MAX_NUMNODES];
@@ -389,6 +389,39 @@ static void dump_numa(unsigned char key)
 
              for_each_online_node(i)
                      printk("    Node %u: %u\n", i, page_num_node[i]);
+
+             if ( d->vnuma )
+             {
+                     printk("    Domain has %u vnodes, %u vcpus\n",
+                                d->vnuma->nr_vnodes, d->max_vcpus);
+                     for ( i = 0; i < d->vnuma->nr_vnodes; i++ )
+                     {
+                             err = snprintf(keyhandler_scratch, 12, "%u",
+                                                    d->vnuma->vnode_to_pnode[i]);
+                             if ( err < 0 || d->vnuma->vnode_to_pnode[i] == NUMA_NO_NODE )
+                                     snprintf(keyhandler_scratch, 3, "???");
+                             printk("        vnode %3u - pnode %s,", i, keyhandler_scratch);
+
+                             printk(" %"PRIu64" MB, ",
+                                        (d->vnuma->vmemrange[i].end - d->vnuma->vmemrange[i].start) >> 20);
+
+                             printk("vcpu nrs: ");
+                             for ( j = 0, n = 0; j < d->max_vcpus; j++ )
+                             {
+                                     if ( d->vnuma->vcpu_to_vnode[j] == i )
+                                     {
+                                             if ( ((n + 1) % 8) == 0 )
+                                                     printk("%d\n", j);
+                                             else if ( !(n % 8) && n != 0 )
+                                                     printk("%s%d ", "             ", j);
+                                             else
+                                                     printk("%d ", j);
+                                             n++;
+                                     }
+                             }
+                             printk("\n");
+                     }
+             }
      }
 
Quoted 4 lines
Quoted 4 lines
xen/arch/x86/numa.c +0 -1
      rcu_read_unlock(&domlist_read_lock);
--

1.7.10.4

Thanks Konrad!

Will be posting tonight next version.

Signature · 1 line
Elena