From nobody Wed Feb 11 04:39:53 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.zoho.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 1498473036624116.52722456510458; Mon, 26 Jun 2017 03:30:36 -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 65B733B73D; Mon, 26 Jun 2017 10:30:33 +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 19AB57EA30; Mon, 26 Jun 2017 10:30:33 +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 068BB3FADF; Mon, 26 Jun 2017 10:30:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5QAUPpR012309 for ; Mon, 26 Jun 2017 06:30:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id D9967788FF; Mon, 26 Jun 2017 10:30:25 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B415E1717A; Mon, 26 Jun 2017 10:30:23 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 CEEEF8046A; Mon, 26 Jun 2017 10:30:21 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2017 03:30:18 -0700 Received: from s2600wt.sh.intel.com ([10.239.48.36]) by fmsmga004.fm.intel.com with ESMTP; 26 Jun 2017 03:30:17 -0700 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 65B733B73D Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=intel.com Authentication-Results: ext-mx06.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 65B733B73D DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CEEEF8046A Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=intel.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=liyong.qiao@intel.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CEEEF8046A X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,395,1493708400"; d="scan'208";a="278661402" From: Eli Qiao To: libvir-list@redhat.com Date: Mon, 26 Jun 2017 18:33:39 +0800 Message-Id: <1498473220-23197-2-git-send-email-liyong.qiao@intel.com> In-Reply-To: <1498473220-23197-1-git-send-email-liyong.qiao@intel.com> References: <1498473220-23197-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.28]); Mon, 26 Jun 2017 10:30:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 26 Jun 2017 10:30:22 +0000 (UTC) for IP:'192.55.52.120' DOMAIN:'mga04.intel.com' HELO:'mga04.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) 192.55.52.120 mga04.intel.com 192.55.52.120 mga04.intel.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: mkletzan@redhat.com, liyong.qiao@intel.com Subject: [libvirt] [PATCH 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 26 Jun 2017 10:30:34 +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 | 113 ++++++++++++++++++++++++++++++++++++++= +++- src/conf/domain_conf.h | 19 +++++++ 3 files changed, 160 insertions(+), 1 deletion(-) 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..fa8d03e 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")); @@ -17642,7 +17730,6 @@ virDomainDefParseXML(xmlDocPtr xml, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract vcpusched nodes")); goto error; - } =20 for (i =3D 0; i < n; i++) { if (virDomainVcpuThreadSchedParse(nodes[i], def) < 0) @@ -24390,6 +24477,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 +24545,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