From nobody Wed May 14 06:13:58 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; 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 1527592956955338.92419381263574; Tue, 29 May 2018 04:22:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F02E330C3E50; Tue, 29 May 2018 11:22:34 +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 5F5F3308BDA8; Tue, 29 May 2018 11:22:34 +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 D83FD1800C9B; Tue, 29 May 2018 11:22:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4TBMV0d032618 for ; Tue, 29 May 2018 07:22:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 13C6A1693B; Tue, 29 May 2018 11:22:31 +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 0B77D65F5A for ; Tue, 29 May 2018 11:22:30 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 F145BC0F8FC6 for ; Tue, 29 May 2018 11:22:29 +0000 (UTC) Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 May 2018 04:22:29 -0700 Received: from bing-i9.bj.intel.com ([172.16.182.85]) by orsmga006.jf.intel.com with ESMTP; 29 May 2018 04:22:28 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,456,1520924400"; d="scan'208";a="45609826" From: bing.niu@intel.com To: libvir-list@redhat.com Date: Tue, 29 May 2018 18:58:03 +0800 Message-Id: <1527591483-20151-3-git-send-email-bing.niu@intel.com> In-Reply-To: <1527591483-20151-1-git-send-email-bing.niu@intel.com> References: <1527591483-20151-1-git-send-email-bing.niu@intel.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 29 May 2018 11:22:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 29 May 2018 11:22:30 +0000 (UTC) for IP:'192.55.52.136' DOMAIN:'mga12.intel.com' HELO:'mga12.intel.com' FROM:'bing.niu@intel.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 192.55.52.136 mga12.intel.com 192.55.52.136 mga12.intel.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, Bing Niu , jian-feng.ding@intel.com, rui.zang@yandex.com Subject: [libvirt] [RFC PATCH 2/2] conf: Extend cputune/cachetune to support memory bandwidth allocation 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.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 29 May 2018 11:22:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Bing Niu Extend current cachetune section to support memory bandwidth allocation. Add a new cachetune element llc for memory allocation. As the example below: id --- on which last level cache memory bandwidth to be set bandwidth --- the memory bandwidth percent to set. Signed-off-by: Bing Niu --- src/conf/domain_conf.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++= ---- src/util/virresctrl.c | 7 ++++ 2 files changed, 86 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d6ac47c..aba998d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18578,6 +18578,55 @@ virDomainDefParseBootOptions(virDomainDefPtr def, return ret; } =20 +static int +virDomainCachetuneDefParseMemoryBandwidth(xmlXPathContextPtr ctxt, + xmlNodePtr node, + virResctrlAllocPtr alloc) +{ + xmlNodePtr oldnode =3D ctxt->node; + unsigned int id; + unsigned int bandwidth; + char *tmp =3D NULL; + int ret =3D -1; + + ctxt->node =3D node; + + tmp =3D virXMLPropString(node, "id"); + if (!tmp) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing cachetune attribute 'id'")); + goto cleanup; + } + if (virStrToLong_uip(tmp, NULL, 10, &id) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid cachetune attribute 'id' value '%s'"), + tmp); + goto cleanup; + } + VIR_FREE(tmp); + + tmp =3D virXMLPropString(node, "bandwidth"); + if (!tmp) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing cachetune attribute 'bandwidth'")); + goto cleanup; + } + if (virStrToLong_uip(tmp, NULL, 10, &bandwidth) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid cachetune attribute 'bandwidth' value '%= s'"), + tmp); + goto cleanup; + } + VIR_FREE(tmp); + if (virResctrlSetMemoryBandwidth(alloc, id, bandwidth) < 0) + goto cleanup; + + ret =3D 0; + cleanup: + ctxt->node =3D oldnode; + VIR_FREE(tmp); + return ret; +} =20 static int virDomainCachetuneDefParseCache(xmlXPathContextPtr ctxt, @@ -18670,6 +18719,7 @@ virDomainCachetuneDefParse(virDomainDefPtr def, ssize_t i =3D 0; int n; int ret =3D -1; + bool mba_available =3D false; =20 ctxt->node =3D node; =20 @@ -18701,12 +18751,26 @@ virDomainCachetuneDefParse(virDomainDefPtr def, goto cleanup; } =20 + if ((n =3D virXPathNodeSet("./llc", ctxt, &nodes)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot extract Memory Bandwidth nodes under " + "cachetune. try cache allocation")); + } + + for (i =3D 0; i < n; i++) { + if (virDomainCachetuneDefParseMemoryBandwidth(ctxt, nodes[i], allo= c) < 0) + goto cleanup; + } + + if (n) + mba_available =3D true; + if ((n =3D virXPathNodeSet("./cache", ctxt, &nodes)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot extract cache nodes under cachetune")); - goto cleanup; + if (!mba_available) + goto cleanup; } - for (i =3D 0; i < n; i++) { if (virDomainCachetuneDefParseCache(ctxt, nodes[i], alloc) < 0) goto cleanup; @@ -26394,11 +26458,19 @@ virDomainCachetuneDefFormatHelper(unsigned int le= vel, virBufferPtr buf =3D opaque; unsigned long long short_size =3D virFormatIntPretty(size, &unit); =20 - virBufferAsprintf(buf, - "\n", - cache, level, virCacheTypeToString(type), - short_size, unit); + /* If type is VIR_CACHE_TYPE_LAST, this means it's a memory + * bandwidth allocation formatting request */ + if (type =3D=3D VIR_CACHE_TYPE_LAST) + virBufferAsprintf(buf, + "\n", + cache, size); + + else + virBufferAsprintf(buf, + "\n", + cache, level, virCacheTypeToString(type), + short_size, unit); =20 return 0; } diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index ad050c7..c720074 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -954,6 +954,13 @@ virResctrlAllocForeachSize(virResctrlAllocPtr resctrl, } } =20 + if (resctrl->mba) { + virResctrlAllocMBPtr mba =3D resctrl->mba; + for (cache =3D 0; cache < mba->nsizes; cache++) + if (mba->bandwidth[cache]) + cb(0, VIR_CACHE_TYPE_LAST, cache, *mba->bandwidth[cache], = opaque); + } + return 0; } =20 --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list