Skip to contentSkip to conversation

libxc: Plumb Xen with vNUMA topology for domain.

PATCH Superseded Elena Ufimtseva 2 participants 2 messages Nov 14, 2013

v2 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/7 libxc: Plumb Xen with vNUMA topology for domain.

Per-domain vNUMA topology initialization.
domctl hypercall is used to set vNUMA topology
per domU during domain build time.

---
 tools/libxc/xc_dom.h    |    9 +++++++
 tools/libxc/xc_domain.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++
 tools/libxc/xenctrl.h   |    9 +++++++
 3 files changed, 79 insertions(+)
tools/libxc/xc_dom.h +9 -0
index 86e23ee..42a16c9 100644
@@ -114,6 +114,15 @@ struct xc_dom_image {
     struct xc_dom_phys *phys_pages;
     int realmodearea_log;
 
+    /*
+     * vNUMA topology and memory allocation structure.
+     * Defines the way to allocate memory on per NUMA
+     * physical nodes that is defined by vnode_numamap.
+     */
+    uint32_t nr_vnodes;
+    uint64_t *vnuma_memszs;
+    unsigned int *vnode_numamap;
+
     /* malloc memory pool */
     struct xc_dom_mem *memblocks;
 
tools/libxc/xc_domain.c +61 -0

67 lines not on this page · raw message

tools/libxc/xenctrl.h +9 -0
index 8cf3f3b..451660e 100644
@@ -1108,6 +1108,15 @@ int xc_domain_set_memmap_limit(xc_interface *xch,
                                uint32_t domid,
                                unsigned long map_limitkb);
 
+int xc_domain_setvnodes(xc_interface *xch,
+                        uint32_t domid,
+                        uint16_t nr_vnodes,
+                        uint16_t nr_vcpus,
+                        vmemrange_t *vmemrange,
+                        unsigned int *vdistance,
+                        unsigned int *vcpu_to_vnode,
+                        unsigned int *vnode_numamap);
+
 #if defined(__i386__) || defined(__x86_64__)
 /*
  * PC BIOS standard E820 types and structure.
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 5 lines · Elena Ufimtseva
tools/libxc/xc_dom.h +0 -0
@@ -114,6 +114,15 @@ struct xc_dom_image {
     struct xc_dom_phys *phys_pages;
     int realmodearea_log;
 

tools/libxc/xc_dom.h struct xc_dom_image { · line 126

Quoted 10 lines
tools/libxc/xc_dom.h +9 -0
+    /*
+     * vNUMA topology and memory allocation structure.
+     * Defines the way to allocate memory on per NUMA
+     * physical nodes that is defined by vnode_numamap.
+     */
+    uint32_t nr_vnodes;
+    uint64_t *vnuma_memszs;
+    unsigned int *vnode_numamap;
+
 

This vnode_numamap is, basically vnode-to-pnode mapping, isn't it? If yes, considering you have vcpu_to_vnode already, what about actually calling it vnode_to_pnode (or something similar)?

Here in Xen (either hypervisor or toolstack), hinting to 'map' and 'mapping', especially when there is memory involved, tend to have a completely different meaning...

Quoted 7 lines
tools/libxc/xc_domain.c +4 -0
 
+/* Plumbs Xen with vNUMA topology */
+int xc_domain_setvnodes(xc_interface *xch,
+                        uint32_t domid,
+                        uint16_t nr_vnodes,

tools/libxc/xc_domain.c int xc_domain_set_max_evtchn(xc_interface *xch, uint32_t domid, · line 1792

Quoted 10 lines
tools/libxc/xc_domain.c +10 -0
+                        uint16_t nr_vcpus,
+                        vmemrange_t *vmemrange,
+                        unsigned int *vdistance,
+                        unsigned int *vcpu_to_vnode,
+                        unsigned int *vnode_numamap)
+{
+    int rc;
+    DECLARE_DOMCTL;
+    DECLARE_HYPERCALL_BOUNCE(vmemrange, sizeof(*vmemrange) * nr_vnodes,
+                                    XC_HYPERCALL_BUFFER_BOUNCE_BOTH);

These all should be XC_HYPERCALL_BUFFER_BOUNCE_IN, I think.

You don't really do any copy_to_guest() in 1/7 for any of these parameters, and, at the same time, you really don't expect, here, to get something back from the hypervisor in them, do you?

tools/libxc/xc_domain.c int xc_domain_set_max_evtchn(xc_interface *xch, uint32_t domid, · line 1803

Quoted 12 lines
tools/libxc/xc_domain.c +11 -0
+    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_numamap, sizeof(*vnode_numamap) *
+                                    nr_vnodes,
+                                    XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+    if ( nr_vnodes == 0 )
+        return -EINVAL;
+

Oh, how funny, we were just talking about this with Konrad the other day. :-)

So, my impression is that, in libxc, we return 0 on success and, in case of error, we return -1 and set errno. So, whenever it is another xc call that fails, you can rely on it having set errno properly and just return -1. If it's you, like in this case, you should be the one setting errno (and returning -1).

Again, this is what I've always done and what I find the most common in libxc. Perhaps we need a word from one of the maintainer to enlighten us about what's the best practise here.

If I'm right, pretty much all the error handling should be changed in this patch, and I'll avoid pointing at all the occurrences here.

tools/libxc/xc_domain.c int xc_domain_set_max_evtchn(xc_interface *xch, uint32_t domid, · line 1805

Quoted 3 lines
tools/libxc/xc_domain.c +2 -0
+    if ( vdistance == NULL || vcpu_to_vnode == NULL ||
+         vmemrange == NULL || vnode_numamap == NULL ) {

Mmm... didn't we say in the previous patch (1/7, the one implementing this DOMCTL in xen) that it is fine for vnode_numamap to be NULL? If we error out like this here, how will ever Xen see it being NULL?

Quoted 14 lines
tools/libxc/xc_domain.c +5 -0
+        PERROR("Incorrect parameters for XEN_DOMCTL_setvnumainfo.\n");
+        return -EINVAL;
+    }
+    
+    rc = -EFAULT;
tools/libxc/xenctrl.h +0 -0
index 8cf3f3b..451660e 100644
@@ -1108,6 +1108,15 @@ int xc_domain_set_memmap_limit(xc_interface *xch,
                                uint32_t domid,
                                unsigned long map_limitkb);
 

tools/libxc/xenctrl.h int xc_domain_set_memmap_limit(xc_interface *xch, · line 1120

Quoted 10 lines
tools/libxc/xenctrl.h +9 -0
+int xc_domain_setvnodes(xc_interface *xch,
+                        uint32_t domid,
+                        uint16_t nr_vnodes,
+                        uint16_t nr_vcpus,
+                        vmemrange_t *vmemrange,
+                        unsigned int *vdistance,
+                        unsigned int *vcpu_to_vnode,
+                        unsigned int *vnode_numamap);
+
 

This is a minor thing, but I wonder whether xc_domain_setvnuma() wouldn't make a better name for this. Thoughts?

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

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