From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: [PATCH RESEND 09/12] libxc: numa-sched: enable getting/specifying per-vcpu node-affinity Date: Tue, 05 Nov 2013 15:35:42 +0100 Message-ID: <20131105143542.30446.5398.stgit@Solace> References: <20131105142844.30446.78671.stgit@Solace> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20131105142844.30446.78671.stgit@Solace> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Marcus Granado , Keir Fraser , Ian Campbell , Li Yechen , George Dunlap , Andrew Cooper , Juergen Gross , Ian Jackson , Jan Beulich , Justin Weaver , Daniel De Graaf , Matt Wilson , Elena Ufimtseva List-Id: xen-devel@lists.xenproject.org by providing the proper get/set interfaces and wiring them to the new domctl-s from the previous commit. Signed-off-by: Dario Faggioli --- tools/libxc/xc_domain.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++ tools/libxc/xenctrl.h | 19 +++++++++++ 2 files changed, 101 insertions(+) diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index f8825a3..e44ad2e 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -272,6 +272,88 @@ out: return ret; } +int xc_vcpu_setnodeaffinity(xc_interface *xch, + uint32_t domid, + int vcpu, + xc_nodemap_t nodemap) +{ + DECLARE_DOMCTL; + DECLARE_HYPERCALL_BUFFER(uint8_t, local); + int ret = -1; + int nodesize; + + nodesize = xc_get_cpumap_size(xch); + if (!nodesize) + { + PERROR("Could not get number of nodes"); + goto out; + } + + local = xc_hypercall_buffer_alloc(xch, local, nodesize); + if ( local == NULL ) + { + PERROR("Could not allocate memory for setvcpunodeaffinity domctl hypercall"); + goto out; + } + + domctl.cmd = XEN_DOMCTL_setvcpunodeaffinity; + domctl.domain = (domid_t)domid; + domctl.u.vcpuaffinity.vcpu = vcpu; + + memcpy(local, nodemap, nodesize); + + set_xen_guest_handle(domctl.u.vcpuaffinity.map.bitmap, local); + + domctl.u.vcpuaffinity.map.nr_bits = nodesize * 8; + + ret = do_domctl(xch, &domctl); + + xc_hypercall_buffer_free(xch, local); + + out: + return ret; +} + +int xc_vcpu_getnodeaffinity(xc_interface *xch, + uint32_t domid, + int vcpu, + xc_nodemap_t nodemap) +{ + DECLARE_DOMCTL; + DECLARE_HYPERCALL_BUFFER(uint8_t, local); + int ret = -1; + int nodesize; + + nodesize = xc_get_nodemap_size(xch); + if (!nodesize) + { + PERROR("Could not get number of nodes"); + goto out; + } + + local = xc_hypercall_buffer_alloc(xch, local, nodesize); + if (local == NULL) + { + PERROR("Could not allocate memory for getvcpunodeaffinity domctl hypercall"); + goto out; + } + + domctl.cmd = XEN_DOMCTL_getvcpunodeaffinity; + domctl.domain = (domid_t)domid; + domctl.u.vcpuaffinity.vcpu = vcpu; + + set_xen_guest_handle(domctl.u.vcpuaffinity.map.bitmap, local); + domctl.u.vcpuaffinity.map.nr_bits = nodesize * 8; + + ret = do_domctl(xch, &domctl); + + memcpy(nodemap, local, nodesize); + + xc_hypercall_buffer_free(xch, local); +out: + return ret; +} + int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid, unsigned int *guest_width) { diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index 8cf3f3b..208fa2c 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -551,6 +551,25 @@ int xc_domain_node_getaffinity(xc_interface *xch, uint32_t domind, xc_nodemap_t nodemap); +/** + * These functions set and retrieves the NUMA node-affinity + * of a specific vcpu. + * + * @parm xch a handle to an open hypervisor interface. + * @parm domid the domain id one is interested in. + * @parm vcpu the vcpu one wants to set/get the affinity of. + * @parm nodemap the map of the affine nodes. + * @return 0 on success, -1 on failure. + */ +int xc_vcpu_setnodeaffinity(xc_interface *xch, + uint32_t domid, + int vcpu, + xc_nodemap_t nodemap); +int xc_vcpu_getnodeaffinity(xc_interface *xch, + uint32_t domid, + int vcpu, + xc_nodemap_t nodemap); + int xc_vcpu_setaffinity(xc_interface *xch, uint32_t domid, int vcpu,