From nobody Thu May 15 08:59:01 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.zohomail.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 1509637675377239.96073825630174; Thu, 2 Nov 2017 08:47:55 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 441F45F7BF; Thu, 2 Nov 2017 15:47:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 15CEF60C9F; Thu, 2 Nov 2017 15:47: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 C398214B20; Thu, 2 Nov 2017 15:47:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vA2FlpA2025045 for ; Thu, 2 Nov 2017 11:47:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id E19AB60460; Thu, 2 Nov 2017 15:47:51 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD087600C0 for ; Thu, 2 Nov 2017 15:47:51 +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 0A74DD7904 for ; Thu, 2 Nov 2017 15:47:46 +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 vA2Flij3006482 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Nov 2017 15:47:45 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vA2FliiU022284 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Nov 2017 15:47:44 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vA2FliKX007401; Thu, 2 Nov 2017 15:47:44 GMT Received: from nina.dynamic.ziggo.nl (/10.175.172.23) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 02 Nov 2017 08:47:44 -0700 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 441F45F7BF Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 441F45F7BF DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0A74DD7904 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: ext-mx09.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 0A74DD7904 From: Wim Ten Have To: Libvirt Development List Date: Thu, 2 Nov 2017 16:47:22 +0100 Message-Id: <20171102154723.26914-4-wim.ten.have@oracle.com> In-Reply-To: <20171102154723.26914-1-wim.ten.have@oracle.com> References: <20171102154723.26914-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 205 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 02 Nov 2017 15:47:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 02 Nov 2017 15:47:46 +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: -105.101 (RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2, RP_MATCHES_RCVD, SPF_PASS, 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.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Wim ten Have Subject: [libvirt] [PATCH v6 3/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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 02 Nov 2017 15:47: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 20 for remote nodes/sockets." Signed-off-by: Wim ten Have Reviewed-by: Jim Fehlig --- Changes on v1: - Fix function calling (coding) standards. - Use virReportError(...) under all failing circumstances. - Reduce redundant (format->parse) code sorting bitmaps. - Avoid non GNU shorthand notations, difficult code practice. Changes on v2: - Have autonomous defaults applied from virDomainNumaGetNodeDistance. - Automatically make Xen driver simulate vnuma pnodes on non NUMA h/w. - Compute 'memory unit=3D' making it the sum of all node memory. Changes on v4: - Escape virDomainNumaGetNodeCount() if effective. Changes on v5: - User VIR_WARN to warn instead of virReportError() abuse without error. - Have ACPI set by libxlDomainDefPostParse() when virDomainNumaGetNodeCount suggests such for x86_64 under HVM. - Remove VIR_DOMAIN_DEF_PARSE_ABI_UPDATE. --- src/libxl/libxl_conf.c | 119 +++++++++++++++++++++++++++++++++++++++++++= ++++ src/libxl/libxl_domain.c | 7 ++- 2 files changed, 125 insertions(+), 1 deletion(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index ecbabfc79..c0dd634cd 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -593,6 +593,120 @@ 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; + size_t i, j; + size_t nr_nodes; + size_t num_vnuma; + bool simulate =3D false; + virBitmapPtr bitmap =3D NULL; + 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); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("libxl_get_physinfo_info failed")); + return -1; + } + nr_nodes =3D physinfo.nr_nodes; + libxl_physinfo_dispose(&physinfo); + + if (num_vnuma > nr_nodes) { + VIR_WARN("Number of configured numa cells %zu exceeds the physical= available nodes %zu, guest simulates numa", + num_vnuma, nr_nodes); + simulate =3D true; + } + + /* + * allocate the vnuma_nodes for assignment under b_info. + */ + if (VIR_ALLOC_N(vnuma_nodes, num_vnuma) < 0) + return -1; + + /* + * parse the vnuma vnodes data. + */ + for (i =3D 0; i < num_vnuma; i++) { + int cpu; + libxl_bitmap vcpu_bitmap; + libxl_vnode_info *p =3D &vnuma_nodes[i]; + + libxl_vnode_info_init(p); + + /* pnode */ + p->pnode =3D simulate ? 0 : i; + + /* memory size */ + p->memkb =3D virDomainNumaGetNodeMemorySize(numa, i); + + /* vcpus */ + bitmap =3D virDomainNumaGetNodeCpumask(numa, i); + if (bitmap =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("vnuma sibling %zu missing vcpus set"), i); + goto cleanup; + } + + if ((cpu =3D virBitmapNextSetBit(bitmap, -1)) < 0) + 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); + + /* vdistances */ + if (VIR_ALLOC_N(p->distances, num_vnuma) < 0) + goto cleanup; + p->num_distances =3D num_vnuma; + + for (j =3D 0; j < num_vnuma; j++) + p->distances[j] =3D virDomainNumaGetNodeDistance(numa, i, j); + } + + b_info->vnuma_nodes =3D vnuma_nodes; + b_info->num_vnuma_nodes =3D num_vnuma; + + ret =3D 0; + + cleanup: + if (ret) { + for (i =3D 0; i < num_vnuma; i++) { + libxl_vnode_info *p =3D &vnuma_nodes[i]; + + VIR_FREE(p->distances); + } + VIR_FREE(vnuma_nodes); + } + + return ret; +} +#endif + static int libxlDiskSetDiscard(libxl_device_disk *x_disk, int discard) { @@ -2184,6 +2298,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 diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 09bfc88f5..d054b0762 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -415,10 +415,15 @@ libxlDomainDefPostParse(virDomainDefPtr def, if (xenDomainDefAddImplicitInputDevice(def) < 0) return -1; =20 - /* For x86_64 HVM, always enable pae */ + /* For x86_64 HVM */ if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM && def->os.arch =3D=3D VIR_ARCH_X86_64) { + /* always enable pae */ def->features[VIR_DOMAIN_FEATURE_PAE] =3D VIR_TRISTATE_SWITCH_ON; + + /* if vnuma is effective enable acpi */ + if (virDomainNumaGetNodeCount(def->numa) > 0) + def->features[VIR_DOMAIN_FEATURE_ACPI] =3D VIR_TRISTATE_SWITCH= _ON; } =20 return 0; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list