From nobody Fri May 16 10:58:35 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1497293756825984.3206909976253; Mon, 12 Jun 2017 11:55:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3915D5F7B6; Mon, 12 Jun 2017 18:55:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 110A35DC1B; Mon, 12 Jun 2017 18:55:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BF1F71841C45; Mon, 12 Jun 2017 18:55:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5CItXU4006207 for ; Mon, 12 Jun 2017 14:55:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2B32C88C76; Mon, 12 Jun 2017 18:55:33 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 263DF6292B for ; Mon, 12 Jun 2017 18:55:31 +0000 (UTC) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7129DC04B320 for ; Mon, 12 Jun 2017 18:55:24 +0000 (UTC) Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v5CItNTQ001652 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2017 18:55:23 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v5CItNJ1017307 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2017 18:55:23 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v5CItMH6009097; Mon, 12 Jun 2017 18:55:22 GMT Received: from nina.dynamic.ziggo.nl (/10.175.181.218) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 12 Jun 2017 11:55:22 -0700 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3915D5F7B6 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=oracle.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3915D5F7B6 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7129DC04B320 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=oracle.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=wim.ten.have@oracle.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7129DC04B320 From: Wim Ten Have To: Libvirt Development List Date: Mon, 12 Jun 2017 20:54:49 +0200 Message-Id: <20170612185451.15920-3-wim.ten.have@oracle.com> In-Reply-To: <20170612185451.15920-1-wim.ten.have@oracle.com> References: <20170612185451.15920-1-wim.ten.have@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 12 Jun 2017 18:55:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 12 Jun 2017 18:55:24 +0000 (UTC) for IP:'156.151.31.81' DOMAIN:'userp1040.oracle.com' HELO:'userp1040.oracle.com' FROM:'wim.ten.have@oracle.com' RCPT:'' X-RedHat-Spam-Score: -101.63 (BAYES_50, DCC_REPUT_13_19, RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY, USER_IN_WHITELIST) 156.151.31.81 userp1040.oracle.com 156.151.31.81 userp1040.oracle.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Wim ten Have Subject: [libvirt] [RFC PATCH v1 2/4] libxl: vnuma support X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 12 Jun 2017 18:55:54 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Wim ten Have This patch generates a NUMA distance-aware libxl description from the information extracted from a NUMA distance-aware libvirt XML file. By default, if no NUMA node distance information is supplied in the libvirt XML file, this patch uses the distances 10 for local and 21 for remote nodes/sockets." Signed-off-by: Wim ten Have --- src/libxl/libxl_conf.c | 128 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 128 insertions(+) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 04d9dd1..3e1a759 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -617,6 +617,129 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, return 0; } =20 +#ifdef LIBXL_HAVE_VNUMA +static int +libxlMakeVnumaList( + virDomainDefPtr def, + libxl_ctx *ctx, + libxl_domain_config *d_config) +{ + int ret =3D -1; + char *vcpus =3D NULL; + size_t i, j; + size_t nr_nodes; + size_t num_vnuma; + virDomainNumaPtr numa =3D def->numa; + libxl_domain_build_info *b_info =3D &d_config->b_info; + libxl_physinfo physinfo; + libxl_vnode_info *vnuma_nodes =3D NULL; + + if (!numa) + return 0; + + num_vnuma =3D virDomainNumaGetNodeCount(numa); + if (!num_vnuma) + return 0; + + libxl_physinfo_init(&physinfo); + if (libxl_get_physinfo(ctx, &physinfo) < 0) { + libxl_physinfo_dispose(&physinfo); + VIR_WARN("libxl_get_physinfo failed"); + goto cleanup; + } + nr_nodes =3D physinfo.nr_nodes; + libxl_physinfo_dispose(&physinfo); + + if (num_vnuma > nr_nodes) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Number of configured numa cells %zu exceeds the = physical available nodes %zu"), + num_vnuma, nr_nodes); + goto cleanup; + } + + /* + * allocate the vnuma_nodes for assignment under b_info. + */ + if (VIR_ALLOC_N(vnuma_nodes, num_vnuma) < 0) + goto cleanup; + + /* + * parse the vnuma vnodes data. + */ + for (i =3D 0; i < num_vnuma; i++) { + int cpu; + virBitmapPtr bitmap =3D NULL; + libxl_bitmap vcpu_bitmap; + libxl_vnode_info *p =3D &vnuma_nodes[i]; + + libxl_vnode_info_init(p); + + /* pnode */ + p->pnode =3D i; + + /* memory size */ + p->memkb =3D virDomainNumaGetNodeMemorySize(numa, i); + + /* vcpus */ + vcpus =3D virBitmapFormat(virDomainNumaGetNodeCpumask(numa, i)); + if (vcpus =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("vnuma sibling %zu missing vcpus set"), i); + goto cleanup; + } + + if (virBitmapParse(vcpus, &bitmap, VIR_DOMAIN_CPUMASK_LEN) < 0) + goto cleanup; + + if ((cpu =3D virBitmapNextSetBit(bitmap, -1)) < 0) { + VIR_FREE(bitmap); + goto cleanup; + } + + libxl_bitmap_init(&vcpu_bitmap); + if (libxl_cpu_bitmap_alloc(ctx, &vcpu_bitmap, b_info->max_vcpus)) { + virReportOOMError(); + goto cleanup; + } + + do { + libxl_bitmap_set(&vcpu_bitmap, cpu); + } while ((cpu =3D virBitmapNextSetBit(bitmap, cpu)) >=3D 0); + + libxl_bitmap_copy_alloc(ctx, &p->vcpus, &vcpu_bitmap); + libxl_bitmap_dispose(&vcpu_bitmap); + + VIR_FREE(bitmap); + VIR_FREE(vcpus); + + /* vdistances */ + if (VIR_ALLOC_N(p->distances, num_vnuma) < 0) + goto cleanup; + p->num_distances =3D num_vnuma; + + /* + * Apply the configured distance value. If not + * available set 10 for local or 21 for remote nodes. + */ + for (j =3D 0; j < num_vnuma; j++) + p->distances[j] =3D virDomainNumaGetNodeDistance(numa, i, j) ?: + (i =3D=3D j ? 10 : 21); + } + + b_info->vnuma_nodes =3D vnuma_nodes; + b_info->num_vnuma_nodes =3D num_vnuma; + + ret =3D 0; + + cleanup: + if (ret) + VIR_FREE(vnuma_nodes); + VIR_FREE(vcpus); + + return ret; +} +#endif + static int libxlDiskSetDiscard(libxl_device_disk *x_disk, int discard) { @@ -2207,6 +2330,11 @@ libxlBuildDomainConfig(virPortAllocatorPtr graphicsp= orts, if (libxlMakeDomBuildInfo(def, ctx, caps, d_config) < 0) return -1; =20 +#ifdef LIBXL_HAVE_VNUMA + if (libxlMakeVnumaList(def, ctx, d_config) < 0) + return -1; +#endif + if (libxlMakeDiskList(def, d_config) < 0) return -1; =20 --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list