From nobody Mon Dec 15 23:51:14 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 1499222301506622.224981958032; Tue, 4 Jul 2017 19:38:21 -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 1CCF7A145A; Wed, 5 Jul 2017 02:38:19 +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 3532B5D72C; Wed, 5 Jul 2017 02:38:18 +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 2DB2D4A492; Wed, 5 Jul 2017 02:38:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v652cC2S019431 for ; Tue, 4 Jul 2017 22:38:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id A0A405D744; Wed, 5 Jul 2017 02:38:12 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 154434F9EE; Wed, 5 Jul 2017 02:38:11 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 E0180624C6; Wed, 5 Jul 2017 02:38:08 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP; 04 Jul 2017 19:38:08 -0700 Received: from s2600wt.sh.intel.com ([10.239.48.36]) by orsmga003.jf.intel.com with ESMTP; 04 Jul 2017 19:38:07 -0700 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1CCF7A145A Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=intel.com Authentication-Results: ext-mx01.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 1CCF7A145A DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E0180624C6 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=intel.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=liyong.qiao@intel.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E0180624C6 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,310,1496127600"; d="scan'208";a="988753385" From: Eli Qiao To: libvir-list@redhat.com Date: Wed, 5 Jul 2017 10:39:03 +0800 Message-Id: <1499222344-24961-2-git-send-email-liyong.qiao@intel.com> In-Reply-To: <1499222344-24961-1-git-send-email-liyong.qiao@intel.com> References: <1499222344-24961-1-git-send-email-liyong.qiao@intel.com> 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.39]); Wed, 05 Jul 2017 02:38:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 05 Jul 2017 02:38:09 +0000 (UTC) for IP:'134.134.136.100' DOMAIN:'mga07.intel.com' HELO:'mga07.intel.com' FROM:'liyong.qiao@intel.com' RCPT:'' X-RedHat-Spam-Score: -1.902 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_PASS) 134.134.136.100 mga07.intel.com 134.134.136.100 mga07.intel.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: mkletzan@redhat.com, liyong.qiao@intel.com Subject: [libvirt] [PATCH RESEND RFC V2 1/2] Resctrl: Add new xml element to support cache tune 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.25]); Wed, 05 Jul 2017 02:38:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch adds new xml element to support cache tune as: ... ... cacheId: reference of the host's cache banks id, it's from capabilities xml. type: cache bank type, it could be both, code, data. sizeKiB: must be multiple of granularity, must be greater than or equal to minimum. vcpus: cache allocation on vcpu set, if empty, will apply the allocation on all vcpus. Signed-off-by: Eli Qiao --- docs/schemas/domaincommon.rng | 29 +++++++++++ src/conf/domain_conf.c | 112 ++++++++++++++++++++++++++++++++++++++= ++++ src/conf/domain_conf.h | 19 +++++++ 3 files changed, 160 insertions(+) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index e259e3e..6e0262e 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -834,6 +834,25 @@ + + + + + + + + + + + + + + + + + + + @@ -5693,6 +5712,16 @@ -1 + + + [0-9]+ + + + + + (both|code|data) + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0409c62..65a9486 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2927,6 +2927,11 @@ void virDomainDefFree(virDomainDefPtr def) =20 xmlFreeNode(def->metadata); =20 + for (i =3D 0; i < def->cachetune.n_banks; i++) + virBitmapFree(def->cachetune.cache_banks[i].vcpus); + + VIR_FREE(def->cachetune.cache_banks); + VIR_FREE(def); } =20 @@ -16318,6 +16323,81 @@ virDomainVcpuPinDefParseXML(virDomainDefPtr def, return ret; } =20 +/* Parse the XML definition for cachetune + * and a cachetune has the form + * + */ +static int +virDomainCacheTuneDefParseXML(virDomainDefPtr def, + int n, + xmlNodePtr* nodes) +{ + char* tmp =3D NULL; + size_t i; + int type =3D -1; + virDomainCacheBankPtr bank =3D NULL; + + if (VIR_ALLOC_N(bank, n) < 0) + goto cleanup; + + for (i =3D 0; i < n; i++) { + if (!(tmp =3D virXMLPropString(nodes[i], "cacheId"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", _("missing cacheId in = cache tune")); + goto cleanup; + } + if (virStrToLong_uip(tmp, NULL, 10, &(bank[i].cache_id)) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("invalid setting for cacheId '%s'"), tmp); + goto cleanup; + } + VIR_FREE(tmp); + + if (!(tmp =3D virXMLPropString(nodes[i], "type"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing cache type")); + goto cleanup; + } + if ((type =3D virCacheTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("'unsupported cache type '%s'"), tmp); + goto cleanup; + } + VIR_FREE(tmp); + + if (!(tmp =3D virXMLPropString(nodes[i], "sizeKiB"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", _("missing sizeKiB in = cache tune")); + goto cleanup; + } + if (virStrToLong_ull(tmp, NULL, 10, &(bank[i].size)) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("invalid setting for cache sizeKiB '%s'"), tm= p); + goto cleanup; + } + /* convert to B */ + bank[i].size *=3D 1024; + VIR_FREE(tmp); + + if ((tmp =3D virXMLPropString(nodes[i], "vcpus"))) { + if (virBitmapParse(tmp, &bank[i].vcpus, VIR_DOMAIN_CPUMASK_LEN= ) < 0) + goto cleanup; + + if (virBitmapIsAllClear(bank[i].vcpus)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Invalid value of vcpus '%s'"), tmp); + goto cleanup; + } + } + } + + def->cachetune.cache_banks =3D bank; + def->cachetune.n_banks =3D n; + return 0; + + cleanup: + VIR_FREE(bank); + VIR_FREE(tmp); + return -1; +} =20 /* Parse the XML definition for a iothreadpin * and an iothreadspin has the form @@ -17606,6 +17686,14 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes); =20 + if ((n =3D virXPathNodeSet("./cputune/cachetune", ctxt, &nodes)) < 0) + goto error; + + if (n > 0 && virDomainCacheTuneDefParseXML(def, n, nodes) < 0) + goto error; + + VIR_FREE(nodes); + if ((n =3D virXPathNodeSet("./cputune/emulatorpin", ctxt, &nodes)) < 0= ) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract emulatorpin nodes")); @@ -24390,6 +24478,28 @@ virDomainSchedulerFormat(virBufferPtr buf, } =20 =20 +static void +virDomainCacheTuneDefFormat(virBufferPtr buf, + virDomainCachetunePtr cache) +{ + size_t i; + + for (i =3D 0; i < cache->n_banks; i ++) { + virBufferAsprintf(buf, "cache_banks[i].cache_id, + virCacheTypeToString(cache->cache_banks[i].= type), + cache->cache_banks[i].size / 1024); + + if (cache->cache_banks[i].vcpus) + virBufferAsprintf(buf, " vcpus=3D'%s'/>\n", + virBitmapFormat(cache->cache_banks[i].vcpus)); + else + virBufferAddLit(buf, "/>\n"); + } +} + + static int virDomainCputuneDefFormat(virBufferPtr buf, virDomainDefPtr def) @@ -24436,6 +24546,8 @@ virDomainCputuneDefFormat(virBufferPtr buf, "\n", def->cputune.iothread_quota); =20 + virDomainCacheTuneDefFormat(&childrenBuf, &def->cachetune); + for (i =3D 0; i < def->maxvcpus; i++) { char *cpumask; virDomainVcpuDefPtr vcpu =3D def->vcpus[i]; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 6d9ee97..729b676 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2190,6 +2190,23 @@ struct _virDomainMemtune { int allocation; /* enum virDomainMemoryAllocation */ }; =20 +typedef struct _virDomainCacheBank virDomainCacheBank; +typedef virDomainCacheBank *virDomainCacheBankPtr; + +struct _virDomainCacheBank { + unsigned int cache_id; /* cache id to be allocated on */ + int type; /* enum virCacheType */ + unsigned long long size; /* in B */ + virBitmapPtr vcpus; +}; + +typedef struct _virDomainCachetune virDomainCachetune; +typedef virDomainCachetune *virDomainCachetunePtr; +struct _virDomainCachetune { + size_t n_banks; + virDomainCacheBankPtr cache_banks; +}; + typedef struct _virDomainPowerManagement virDomainPowerManagement; typedef virDomainPowerManagement *virDomainPowerManagementPtr; =20 @@ -2263,6 +2280,8 @@ struct _virDomainDef { =20 virDomainCputune cputune; =20 + virDomainCachetune cachetune; + virDomainNumaPtr numa; virDomainResourceDefPtr resource; virDomainIdMapDef idmap; --=20 1.9.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list