From nobody Mon Feb 9 13:57:52 2026 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; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535373580294619.6078210714195; Mon, 27 Aug 2018 05:39:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D1008553C; Mon, 27 Aug 2018 12:39:38 +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 1829C19E1C; Mon, 27 Aug 2018 12:39:38 +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 BACC124F5A; Mon, 27 Aug 2018 12:39:37 +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 w7RBO3Ll024666 for ; Mon, 27 Aug 2018 07:24:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id BDDF860157; Mon, 27 Aug 2018 11:24:03 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6A4619CBA for ; Mon, 27 Aug 2018 11:24:01 +0000 (UTC) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 8E9FB30832C8 for ; Mon, 27 Aug 2018 11:24:00 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Aug 2018 04:23:56 -0700 Received: from david-unc.bj.intel.com ([10.238.145.63]) by fmsmga001.fm.intel.com with ESMTP; 27 Aug 2018 04:23:51 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,295,1531810800"; d="scan'208";a="84804975" From: Wang Huaqiang To: libvir-list@redhat.com Date: Mon, 27 Aug 2018 19:23:11 +0800 Message-Id: <1535368993-24901-9-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1535368993-24901-1-git-send-email-huaqiang.wang@intel.com> References: <1535368993-24901-1-git-send-email-huaqiang.wang@intel.com> 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.44]); Mon, 27 Aug 2018 11:24:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 27 Aug 2018 11:24:00 +0000 (UTC) for IP:'134.134.136.20' DOMAIN:'mga02.intel.com' HELO:'mga02.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 134.134.136.20 mga02.intel.com 134.134.136.20 mga02.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Mon, 27 Aug 2018 08:39:21 -0400 Cc: shaohe.feng@intel.com, Wang Huaqiang , bing.niu@intel.com, jian-feng.ding@intel.com, rui.zang@intel.com Subject: [libvirt] [PATCH 08/10] conf: introduce resctrl monitor group in domain 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 27 Aug 2018 12:39:39 +0000 (UTC) X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Introduce resource monitoring group in domain configuration file to support CPU cache monitoring technology (CMT). Domain rng file changes, supporting following types of resource monitoring group regarding the allocation regin it belongs to: 1. monitoring group that working for partial working thread of current allocation: e.g. "" creates monitoring group special for vcpu '0' while an allocation group is created for vcpus of '0' *and* '1'. 2. monitoring group for whole vcpu set of current allocation: e.g. "" creates monitoring group for all vcpus belonging to current allocation. 3. monitoring group for vcpu(s) that does not have dedicated allocation group: e.g. "" creates a monitoring group but no resource control applied to it. + + + + Signed-off-by: Wang Huaqiang --- docs/formatdomain.html.in | 14 ++- docs/schemas/domaincommon.rng | 11 +- src/conf/domain_conf.c | 131 +++++++++++++++++= +--- src/conf/domain_conf.h | 20 ++++ tests/genericxml2xmlindata/cachetune-cdp.xml | 2 + .../cachetune-colliding-monitors.xml | 36 ++++++ tests/genericxml2xmlindata/cachetune-small.xml | 1 + tests/genericxml2xmlindata/cachetune.xml | 3 + tests/genericxml2xmltest.c | 4 + 9 files changed, 204 insertions(+), 18 deletions(-) create mode 100644 tests/genericxml2xmlindata/cachetune-colliding-monitors= .xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 0cbf570..33d2890 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -758,6 +758,7 @@ <cachetune vcpus=3D'0-3'> <cache id=3D'0' level=3D'3' type=3D'both' size=3D'3' unit=3D'MiB'= /> <cache id=3D'1' level=3D'3' type=3D'both' size=3D'3' unit=3D'MiB'= /> + <monitor vcpus=3D'0-1'/> </cachetune> <memorytune vcpus=3D'0-3'> <node id=3D'0' bandwidth=3D'60'/> @@ -942,8 +943,8 @@
cache
- This element controls the allocation of CPU cache and has the - following attributes: + This optional element controls the allocation of CPU cache and= has + the following attributes:
level
@@ -977,6 +978,15 @@
+
monitor
+
+ The optional element monitor creates the cahce + monitoring group(s) for current cache allocation group. The re= quired + attribute vcpus specifies to which vCPUs this + monitoring group applies. A vCPU can only be member of one + cachetune element allocation. And no overlap is + permitted. +
=20 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index f176538..83fb9b7 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -956,7 +956,7 @@ - + @@ -980,7 +980,14 @@ - + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9a65655..304a94e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2969,13 +2969,30 @@ virDomainLoaderDefFree(virDomainLoaderDefPtr loader) =20 =20 static void +virDomainResctrlMonFree(virDomainResctrlMonitorPtr monitor) +{ + if (!monitor) + return; + + VIR_FREE(monitor->id); + virBitmapFree(monitor->vcpus); + VIR_FREE(monitor); +} + + +static void virDomainResctrlDefFree(virDomainResctrlDefPtr resctrl) { + size_t i =3D 0; + if (!resctrl) return; =20 virObjectUnref(resctrl->alloc); virBitmapFree(resctrl->vcpus); + for (i =3D 0; i < resctrl->nmonitors; i++) + virDomainResctrlMonFree(resctrl->monitors[i]); + VIR_FREE(resctrl->monitors); VIR_FREE(resctrl); } =20 @@ -19298,6 +19315,71 @@ virDomainResctrlAppend(virDomainDefPtr def, =20 =20 static int +virDomainResctrlParseMonitor(virDomainDefPtr def, + xmlXPathContextPtr ctxt, + xmlNodePtr node, + virDomainResctrlDefPtr resctrl) +{ + xmlNodePtr oldnode =3D ctxt->node; + virBitmapPtr vcpus =3D NULL; + char *id =3D NULL; + int vcpu =3D -1; + char *vcpus_str =3D NULL; + virDomainResctrlMonitorPtr tmp_domresmon =3D NULL; + int ret =3D -1; + + if (!resctrl || !resctrl->vcpus || !resctrl->alloc) + return -1; + + ctxt->node =3D node; + + if (VIR_ALLOC(tmp_domresmon) < 0) + goto cleanup; + + if (virDomainResctrlParseVcpus(def, node, &vcpus) < 0) + goto cleanup; + + /* empty monitoring group is not allowed */ + if (virBitmapIsAllClear(vcpus)) + goto cleanup; + + while ((vcpu =3D virBitmapNextSetBit(vcpus, vcpu)) >=3D 0) { + if (!virBitmapIsBitSet(resctrl->vcpus, vcpu)) + goto cleanup; + } + + vcpus_str =3D virBitmapFormat(vcpus); + if (!vcpus_str) + goto cleanup; + + if (virAsprintf(&id, "vcpus_%s", vcpus_str) < 0) + goto cleanup; + + if (VIR_STRDUP(tmp_domresmon->id, id) < 0) + goto cleanup; + + tmp_domresmon->vcpus =3D vcpus; + + if (VIR_APPEND_ELEMENT(resctrl->monitors, + resctrl->nmonitors, + tmp_domresmon) < 0) + goto cleanup; + + if (virResctrlAllocSetMonitor(resctrl->alloc, id) < 0) + goto cleanup; + + tmp_domresmon =3D NULL; + ret =3D 0; + cleanup: + ctxt->node =3D oldnode; + VIR_FREE(id); + VIR_FREE(vcpus_str); + virDomainResctrlMonFree(tmp_domresmon); + return ret; +} + + +static int virDomainCachetuneDefParse(virDomainDefPtr def, xmlXPathContextPtr ctxt, xmlNodePtr node, @@ -19313,6 +19395,9 @@ virDomainCachetuneDefParse(virDomainDefPtr def, int n; int ret =3D -1; =20 + if (VIR_ALLOC(tmp_resctrl) < 0) + return -1; + ctxt->node =3D node; =20 if (virDomainResctrlParseVcpus(def, node, &vcpus) < 0) @@ -19347,30 +19432,40 @@ virDomainCachetuneDefParse(virDomainDefPtr def, goto cleanup; } =20 - if (virResctrlAllocIsEmpty(alloc)) { - ret =3D 0; + tmp_resctrl->vcpus =3D vcpus; + tmp_resctrl->alloc =3D virObjectRef(alloc); + + VIR_FREE(nodes); + ctxt->node =3D node; + + if ((n =3D virXPathNodeSet("./monitor", ctxt, &nodes)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot extract monitor nodes under cachetune")); goto cleanup; } =20 - if (VIR_ALLOC(tmp_resctrl) < 0) - goto cleanup; + for (i =3D 0; i < n; i++) { + if (virDomainResctrlParseMonitor(def, ctxt, + nodes[i], tmp_resctrl) < 0) =20 - tmp_resctrl->vcpus =3D vcpus; - tmp_resctrl->alloc =3D virObjectRef(alloc); + goto cleanup; + } + + if (virResctrlAllocIsEmpty(alloc)) { + VIR_WARN("cachetune: resctrl alloc is empty"); + ret =3D 0; + goto cleanup; + } =20 if (virDomainResctrlAppend(def, node, tmp_resctrl, flags) < 0) goto cleanup; =20 - alloc =3D NULL; - vcpus =3D NULL; tmp_resctrl =3D NULL; =20 ret =3D 0; cleanup: ctxt->node =3D oldnode; - virObjectUnref(alloc); - VIR_FREE(tmp_resctrl); - virBitmapFree(vcpus); + virDomainResctrlDefFree(tmp_resctrl); VIR_FREE(nodes); return ret; } @@ -19588,10 +19683,8 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, ret =3D 0; cleanup: ctxt->node =3D oldnode; - virBitmapFree(vcpus); - virObjectUnref(alloc); - VIR_FREE(tmp_resctrl); VIR_FREE(nodes); + virDomainResctrlDefFree(tmp_resctrl); return ret; } =20 @@ -27394,6 +27487,7 @@ virDomainCachetuneDefFormat(virBufferPtr buf, { virBuffer childrenBuf =3D VIR_BUFFER_INITIALIZER; char *vcpus =3D NULL; + size_t i =3D 0; int ret =3D -1; =20 virBufferSetChildIndent(&childrenBuf, buf); @@ -27405,6 +27499,15 @@ virDomainCachetuneDefFormat(virBufferPtr buf, if (virBufferCheckError(&childrenBuf) < 0) goto cleanup; =20 + for (i =3D 0; i < resctrl->nmonitors; i++) { + vcpus =3D virBitmapFormat(resctrl->monitors[i]->vcpus); + if (!vcpus) + goto cleanup; + + virBufferAsprintf(&childrenBuf, "\n", vcpus= ); + VIR_FREE(vcpus); + } + if (!virBufferUse(&childrenBuf)) { ret =3D 0; goto cleanup; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c0ad072..797b4bd 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2235,12 +2235,31 @@ struct _virDomainCputune { }; =20 =20 +typedef enum { + VIR_DOMAIN_RESCTRL_MONITOR_CACHE, + VIR_DOMAIN_RESCTRL_MONITOR_MEMBW, + VIR_DOMAIN_RESCTRL_MONITOR_CACHE_MEMBW, + + VIR_DOMAIN_RESCTRL_MONITOR_LAST +} virDomainResctrlMonType; + +typedef struct _virDomainResctrlMonitor virDomainResctrlMonitor; +typedef virDomainResctrlMonitor *virDomainResctrlMonitorPtr; +struct _virDomainResctrlMonitor { + int type; /* virDomainResctrlMonType*/ + char *id; + virBitmapPtr vcpus; +}; + + typedef struct _virDomainResctrlDef virDomainResctrlDef; typedef virDomainResctrlDef *virDomainResctrlDefPtr; =20 struct _virDomainResctrlDef { virBitmapPtr vcpus; virResctrlAllocPtr alloc; + virDomainResctrlMonitorPtr *monitors; + size_t nmonitors; }; =20 =20 @@ -3455,6 +3474,7 @@ VIR_ENUM_DECL(virDomainIOMMUModel) VIR_ENUM_DECL(virDomainVsockModel) VIR_ENUM_DECL(virDomainShmemModel) VIR_ENUM_DECL(virDomainLaunchSecurity) +VIR_ENUM_DECL(virDomainResctrlMonType) /* from libvirt.h */ VIR_ENUM_DECL(virDomainState) VIR_ENUM_DECL(virDomainNostateReason) diff --git a/tests/genericxml2xmlindata/cachetune-cdp.xml b/tests/genericxm= l2xmlindata/cachetune-cdp.xml index 9718f06..b257fd5 100644 --- a/tests/genericxml2xmlindata/cachetune-cdp.xml +++ b/tests/genericxml2xmlindata/cachetune-cdp.xml @@ -8,9 +8,11 @@ + + diff --git a/tests/genericxml2xmlindata/cachetune-colliding-monitors.xml b/= tests/genericxml2xmlindata/cachetune-colliding-monitors.xml new file mode 100644 index 0000000..7526070 --- /dev/null +++ b/tests/genericxml2xmlindata/cachetune-colliding-monitors.xml @@ -0,0 +1,36 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 4 + + + + + + + + + + + + + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + diff --git a/tests/genericxml2xmlindata/cachetune-small.xml b/tests/generic= xml2xmlindata/cachetune-small.xml index ab2d9cf..aa7b2c3 100644 --- a/tests/genericxml2xmlindata/cachetune-small.xml +++ b/tests/genericxml2xmlindata/cachetune-small.xml @@ -7,6 +7,7 @@ + diff --git a/tests/genericxml2xmlindata/cachetune.xml b/tests/genericxml2xm= lindata/cachetune.xml index 645cab7..52e95bc 100644 --- a/tests/genericxml2xmlindata/cachetune.xml +++ b/tests/genericxml2xmlindata/cachetune.xml @@ -8,9 +8,12 @@ + + + diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index e6d4ef2..bc2fc50 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -140,11 +140,15 @@ mymain(void) TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); DO_TEST_FULL("cachetune-colliding-types", false, true, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST_FULL("cachetune-colliding-monitors", false, true, + TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); DO_TEST("memorytune"); DO_TEST_FULL("memorytune-colliding-allocs", false, true, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); DO_TEST_FULL("memorytune-colliding-cachetune", false, true, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST_FULL("cachetune-colliding-monitors", false, true, + TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); =20 DO_TEST("tseg"); =20 --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list