From nobody Fri May 3 11:45:28 2024 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 1536646492672417.3213124536496; Mon, 10 Sep 2018 23:14:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A46133082AF3; Tue, 11 Sep 2018 06:14:50 +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 E255B19486; Tue, 11 Sep 2018 06:14:49 +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 90BFE18005D0; Tue, 11 Sep 2018 06:14:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8B6ElHj021260 for ; Tue, 11 Sep 2018 02:14:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id BF8096090E; Tue, 11 Sep 2018 06:14:47 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B68E56090B for ; Tue, 11 Sep 2018 06:14:44 +0000 (UTC) Received: from mxct.zte.com.cn (out1.zte.com.cn [202.103.147.172]) (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 011EA3082AF3 for ; Tue, 11 Sep 2018 06:14:43 +0000 (UTC) Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 179CD327B730C196318D for ; Tue, 11 Sep 2018 14:14:41 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w8B6EYoZ047107 for ; Tue, 11 Sep 2018 14:14:34 +0800 (GMT-8) (envelope-from peng.hao2@zte.com.cn) Received: from localhost.localdomain.localdomain ([10.74.120.59]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018091114143848-8339823 ; Tue, 11 Sep 2018 14:14:38 +0800 From: Peng Hao To: libvir-list@redhat.com Date: Tue, 11 Sep 2018 22:28:10 +0800 Message-Id: <1536676090-92733-1-git-send-email-peng.hao2@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-09-11 14:14:38, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-09-11 14:14:30, Serialize complete at 2018-09-11 14:14:30 X-MAIL: mse01.zte.com.cn w8B6EYoZ047107 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 212 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 11 Sep 2018 06:14:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 11 Sep 2018 06:14:43 +0000 (UTC) for IP:'202.103.147.172' DOMAIN:'out1.zte.com.cn' HELO:'mxct.zte.com.cn' FROM:'peng.hao2@zte.com.cn' RCPT:'' X-RedHat-Spam-Score: -2.3 (DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_MED, SPF_PASS) 202.103.147.172 out1.zte.com.cn 202.103.147.172 out1.zte.com.cn X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peng Hao Subject: [libvirt] [PATCH] add nodeset='all' and default for interleave mode 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 11 Sep 2018 06:14:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For interleave mode,sometimes we want to allocate mmeory regularly in all nodes on the host. But different hosts has different node number. So we add nodeset=3D'all' for interleave mode and if nodeset=3DNULL default nodeset is 'all' for interleave mode. Signed-off-by: Peng Hao --- src/conf/numa_conf.c | 73 ++++++++++++++++++++++++++++++++++++++++--------= ---- 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 97a3ca4..de5fb9c 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -29,6 +29,10 @@ #include "virnuma.h" #include "virstring.h" =20 +#if WITH_NUMACTL +#include +#endif + /* * Distance definitions defined Conform ACPI 2.0 SLIT. * See include/linux/topology.h @@ -66,6 +70,7 @@ typedef virDomainNumaNode *virDomainNumaNodePtr; struct _virDomainNuma { struct { bool specified; + bool allnode; virBitmapPtr nodeset; virDomainNumatuneMemMode mode; virDomainNumatunePlacement placement; @@ -259,13 +264,17 @@ virDomainNumatuneParseXML(virDomainNumaPtr numa, =20 tmp =3D virXMLPropString(node, "nodeset"); if (tmp) { - if (virBitmapParse(tmp, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) - goto cleanup; - - if (virBitmapIsAllClear(nodeset)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Invalid value of 'nodeset': %s"), tmp); - goto cleanup; + if (strcmp(tmp, "all") =3D=3D 0) { + numa->memory.allnode =3D true; + } else { + if (virBitmapParse(tmp, &nodeset, VIR_DOMAIN_CPUMASK_LEN) = < 0) + goto cleanup; + + if (virBitmapIsAllClear(nodeset)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Invalid value of 'nodeset': %s"), tm= p); + goto cleanup; + } } =20 VIR_FREE(tmp); @@ -319,10 +328,14 @@ virDomainNumatuneFormatXML(virBufferPtr buf, virBufferAsprintf(buf, "memory.placement =3D=3D VIR_DOMAIN_NUMATUNE_PLACEMEN= T_STATIC) { - if (!(nodeset =3D virBitmapFormat(numatune->memory.nodeset))) - return -1; - virBufferAsprintf(buf, "nodeset=3D'%s'/>\n", nodeset); - VIR_FREE(nodeset); + if (numatune->memory.allnode =3D=3D true) { =20 + virBufferAsprintf(buf, "nodeset=3D'all'/>\n"); + } else { + if (!(nodeset =3D virBitmapFormat(numatune->memory.nodeset= ))) + return -1; + virBufferAsprintf(buf, "nodeset=3D'%s'/>\n", nodeset); + VIR_FREE(nodeset); + } } else if (numatune->memory.placement) { tmp =3D virDomainNumatunePlacementTypeToString(numatune->memor= y.placement); virBufferAsprintf(buf, "placement=3D'%s'/>\n", tmp); @@ -497,6 +510,9 @@ virDomainNumatuneSet(virDomainNumaPtr numa, virBitmapPtr nodeset) { int ret =3D -1; + int i =3D 0, maxnode =3D 0; + virBitmapPtr bitmap =3D NULL; + =20 /* No need to do anything in this case */ if (mode =3D=3D -1 && placement =3D=3D -1 && !nodeset) @@ -538,7 +554,7 @@ virDomainNumatuneSet(virDomainNumaPtr numa, } =20 if (placement =3D=3D VIR_DOMAIN_NUMATUNE_PLACEMENT_DEFAULT) { - if (numa->memory.nodeset || placement_static) + if (numa->memory.nodeset || placement_static || numa->memory.allno= de) placement =3D VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC; else placement =3D VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO; @@ -546,10 +562,35 @@ virDomainNumatuneSet(virDomainNumaPtr numa, =20 if (placement =3D=3D VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC && !numa->memory.nodeset) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("nodeset for NUMA memory tuning must be set " - "if 'placement' is 'static'")); - goto cleanup; + if (mode !=3D VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("nodeset for NUMA memory tuning must be set " + "if 'placement' is 'static'")); + goto cleanup; + } else { + /* default set all node if nodeset is NULL, when placement=20 + * is static and mode is interleave. + */ + numa->memory.allnode =3D true; + } + } + + if (placement =3D=3D VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC && + mode =3D=3D VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE && + numa->memory.allnode) { + if ((bitmap =3D virBitmapNew(VIR_DOMAIN_CPUMASK_LEN)) =3D=3D NULL) + goto cleanup; + virBitmapClearAll(bitmap); + maxnode =3D numa_max_node(); + for (i =3D 0; i <=3D maxnode; i++) { + if (virBitmapSetBit(bitmap, i) < 0) { + virBitmapFree(bitmap); + goto cleanup; + } + } + if (numa->memory.nodeset) + virBitmapFree(numa->memory.nodeset); + numa->memory.nodeset =3D bitmap; } =20 /* setting nodeset when placement auto is invalid */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list