From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: [PATCH RESEND 10/12] libxl: numa-sched: enable getting/specifying per-vcpu node-affinity Date: Tue, 05 Nov 2013 15:35:54 +0100 Message-ID: <20131105143553.30446.11558.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 libxc calls from the previous commit. For the 'get' part, the node-affinity of all the vcpus of a domain is also reported via libxl_list_vcpu() (exactly as it is happening for their vcpu affinity already), adding a specific field to libxl_vcpuinfo. Signed-off-by: Dario Faggioli --- tools/libxl/libxl.c | 28 ++++++++++++++++++++++++++++ tools/libxl/libxl.h | 11 +++++++++++ tools/libxl/libxl_types.idl | 1 + 3 files changed, 40 insertions(+) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 0f0f56c..4a36e70 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -4208,6 +4208,10 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid, LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "allocating cpumap"); return NULL; } + if (libxl_node_bitmap_alloc(ctx, &ptr->nodemap, 0)) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "allocating nodemap"); + return NULL; + } if (xc_vcpu_getinfo(ctx->xch, domid, *nb_vcpu, &vcpuinfo) == -1) { LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting vcpu info"); return NULL; @@ -4216,6 +4220,10 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid, LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting vcpu affinity"); return NULL; } + if (xc_vcpu_getnodeaffinity(ctx->xch, domid, *nb_vcpu, ptr->nodemap.map) == -1) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting node-affinity"); + return NULL; + } ptr->vcpuid = *nb_vcpu; ptr->cpu = vcpuinfo.cpu; ptr->online = !!vcpuinfo.online; @@ -4251,6 +4259,26 @@ int libxl_set_vcpuaffinity_all(libxl_ctx *ctx, uint32_t domid, return rc; } +int libxl_set_vcpunodeaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid, + const libxl_bitmap *nodemap) +{ + if (xc_vcpu_setnodeaffinity(ctx->xch, domid, vcpuid, nodemap->map)) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "setting vcpu node-affinity"); + return ERROR_FAIL; + } + return 0; +} + +int libxl_get_vcpunodeaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid, + libxl_bitmap *nodemap) +{ + if (xc_vcpu_getnodeaffinity(ctx->xch, domid, vcpuid, nodemap->map)) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting vcpu node-affinity"); + return ERROR_FAIL; + } + return 0; +} + int libxl_domain_set_nodeaffinity(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *nodemap) { diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 1c6675d..d5b8ade 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -82,6 +82,13 @@ #define LIBXL_HAVE_DOMAIN_NODEAFFINITY 1 /* + * LIBXL_HAVE_VCPUINFO_NODEAFFINITY indicates that a 'nodemap' field + * (of libxl_bitmap type) is present in libxl_vcpuinfo, containing the + * node-affinity for the vcpu. + */ +#define LIBXL_HAVE_VCPUINFO_NODEAFFINITY + +/* * LIBXL_HAVE_BUILDINFO_HVM_VENDOR_DEVICE indicates that the * libxl_vendor_device field is present in the hvm sections of * libxl_domain_build_info. This field tells libxl which @@ -985,6 +992,10 @@ int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid, libxl_bitmap *cpumap); int libxl_set_vcpuaffinity_all(libxl_ctx *ctx, uint32_t domid, unsigned int max_vcpus, libxl_bitmap *cpumap); +int libxl_set_vcpunodeaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid, + const libxl_bitmap *nodemap); +int libxl_get_vcpunodeaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid, + libxl_bitmap *nodemap); int libxl_domain_set_nodeaffinity(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *nodemap); int libxl_domain_get_nodeaffinity(libxl_ctx *ctx, uint32_t domid, diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 5c43d6f..5c83f98 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -492,6 +492,7 @@ libxl_vcpuinfo = Struct("vcpuinfo", [ ("running", bool), ("vcpu_time", uint64), # total vcpu time ran (ns) ("cpumap", libxl_bitmap), # current cpu's affinities + ("nodemap", libxl_bitmap), # current node-affinity ], dir=DIR_OUT) libxl_physinfo = Struct("physinfo", [