From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: [PATCH 1/2] libxl: turn NUMA placement misconfigs into warnings Date: Wed, 01 Jul 2015 16:03:07 +0200 Message-ID: <20150701140306.15951.83934.stgit@Solace.station> References: <20150701135059.15951.39938.stgit@Solace.station> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZAIbY-0006zP-OR for xen-devel@lists.xenproject.org; Wed, 01 Jul 2015 14:03:12 +0000 Received: by wicgi11 with SMTP id gi11so46523602wic.0 for ; Wed, 01 Jul 2015 07:03:09 -0700 (PDT) In-Reply-To: <20150701135059.15951.39938.stgit@Solace.station> 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.xenproject.org Cc: Wei Liu , Ian Jackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org instead than errors. More specifically, in libxl, b_info->numa_autoplacement is meant as a way to disable automatic NUMA placement, if one does not want it to happen. It is, however, useful for consistency checking as well, i.e., to ensure that the user provided configuration (such as, for instance, vcpu hard or soft affinity) and NUMA placement itself will not clash. However, right now, if such a clash happens we abort domain creation and error out, which is too much! It is, in fact, enough to infom the user/caller that NUMA placement won't be performed, with a WARN, and that's what this commit does. Signed-off-by: Dario Faggioli --- Cc: Ian Jackson Cc: Stefano Stabellini Cc: Ian Campbell Cc: Wei Liu --- tools/libxl/libxl_dom.c | 76 +++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 1c9418a..b9a77a5 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -330,50 +330,48 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid, * reflect the placement result if that is the case */ if (libxl_defbool_val(info->numa_placement)) { - libxl_bitmap cpumap_soft; - - if (info->cpumap.size || - info->num_vcpu_hard_affinity || info->num_vcpu_soft_affinity) { - LOG(ERROR, "Can run NUMA placement only if no vcpu " - "(hard or soft) affinity is specified explicitly"); - return ERROR_INVAL; - } - if (info->nodemap.size) { - LOG(ERROR, "Can run NUMA placement only if the domain does not " - "have any NUMA node affinity set already"); - return ERROR_INVAL; - } - - rc = libxl_node_bitmap_alloc(ctx, &info->nodemap, 0); - if (rc) - return rc; - libxl_bitmap_set_any(&info->nodemap); + if (info->cpumap.size || info->num_vcpu_hard_affinity || + info->num_vcpu_soft_affinity) + LOG(WARN, "Can't run NUMA placement, as an (hard or soft) " + "affinity has been specified explicitly"); + else if (info->nodemap.size) + LOG(WARN, "Can't run NUMA placement, as the domain has " + "NUMA node affinity set already"); + else { + libxl_bitmap cpumap_soft; + + rc = libxl_node_bitmap_alloc(ctx, &info->nodemap, 0); + if (rc) + return rc; + libxl_bitmap_set_any(&info->nodemap); + + rc = libxl_cpu_bitmap_alloc(ctx, &cpumap_soft, 0); + if (rc) + return rc; + + rc = numa_place_domain(gc, domid, info); + if (rc) { + libxl_bitmap_dispose(&cpumap_soft); + return rc; + } - rc = libxl_cpu_bitmap_alloc(ctx, &cpumap_soft, 0); - if (rc) - return rc; + /* + * All we need to do now is converting the result of automatic + * placement from nodemap to cpumap, and then use such cpumap + * as the soft affinity for all the vcpus of the domain. + * + * When calling libxl_set_vcpuaffinity_all(), it is ok to use + * NULL as hard affinity, as we know we don't have one, or we + * won't be here. + */ + libxl_nodemap_to_cpumap(ctx, &info->nodemap, &cpumap_soft); + libxl_set_vcpuaffinity_all(ctx, domid, info->max_vcpus, + NULL, &cpumap_soft); - rc = numa_place_domain(gc, domid, info); - if (rc) { libxl_bitmap_dispose(&cpumap_soft); - return rc; } - - /* - * All we need to do now is converting the result of automatic - * placement from nodemap to cpumap, and then use such cpumap as - * the soft affinity for all the vcpus of the domain. - * - * When calling libxl_set_vcpuaffinity_all(), it is ok to use NULL - * as hard affinity, as we know we don't have one, or we won't be - * here. - */ - libxl_nodemap_to_cpumap(ctx, &info->nodemap, &cpumap_soft); - libxl_set_vcpuaffinity_all(ctx, domid, info->max_vcpus, - NULL, &cpumap_soft); - - libxl_bitmap_dispose(&cpumap_soft); } + if (info->nodemap.size) libxl_domain_set_nodeaffinity(ctx, domid, &info->nodemap);