Enable l3code/l3data while doing cache tune. l3code/l3data should use a continus cbm in their seperated schemata and the cache size are shared between them, so we need to deal them differently with l3 cache. This should enable cdp feature while mounting /sys/fs/resctrl, eg: mount -t resctrl resctrl -o cdp /sys/fs/resctrl Signed-off-by: Eli Qiao <liyong.qiao@xxxxxxxxx> --- docs/schemas/domaincommon.rng | 2 +- src/util/virresctrl.c | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index edb2888..f61c57a 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5489,7 +5489,7 @@ </define> <define name="cachetype"> <data type="string"> - <param name="pattern">(l3)</param> + <param name="pattern">(l3|l3code|l3data)</param> </data> </define> <define name="cacheunit"> diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index cb46e36..ba362e4 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -400,6 +400,7 @@ int virResCtrlRefreshSchemata(void) size_t i, j, k; unsigned int tmp_schemata; unsigned int default_schemata; + int pair_type = 0; virResDomainPtr header, p; @@ -410,6 +411,12 @@ int virResCtrlRefreshSchemata(void) for (i = 0; i < VIR_RDT_RESOURCE_LAST; i++) { if (VIR_RESCTRL_ENABLED(i)) { + + if (i == VIR_RDT_RESOURCE_L3DATA) + pair_type = VIR_RDT_RESOURCE_L3CODE; + if (i == VIR_RDT_RESOURCE_L3CODE) + pair_type = VIR_RDT_RESOURCE_L3DATA; + for (j = 0; j < header->schematas[i]->n_schemata_items; j ++) { p = header->next; default_schemata = VIR_RESCTRL_GET_SCHEMATA(resctrlall[i].cbm_len); @@ -417,6 +424,8 @@ int virResCtrlRefreshSchemata(void) /* NOTEs: if only header domain, the schemata will be set to default one*/ for (k = 1; k < domainall.num_domains; k++) { tmp_schemata |= p->schematas[i]->schemata_items[j].schemata; + if (pair_type > 0) + tmp_schemata |= p->schematas[pair_type]->schemata_items[j].schemata; p = p->next; } /* sys fs doens't let us use 0 */ @@ -492,6 +501,7 @@ virResCtrlWrite(const char *name, const char *item, const char *content) goto cleanup; rc = 0; + cleanup: VIR_FREE(path); VIR_FORCE_CLOSE(writefd); @@ -696,6 +706,7 @@ virResCtrlCalculateSchemata(int type, virResDomainPtr p; unsigned int tmp_schemata; unsigned int schemata_sum = 0; + int pair_type = 0; if (resctrlall[type].cache_banks[sid].cache_left < size) { VIR_ERROR(_("Not enough cache left on bank %u"), hostid); @@ -710,8 +721,18 @@ virResCtrlCalculateSchemata(int type, p = domainall.domains; p = p->next; + + /* for type is l3code and l3data, we need to deal them specially*/ + if (type == VIR_RDT_RESOURCE_L3DATA) + pair_type = VIR_RDT_RESOURCE_L3CODE; + + if (type == VIR_RDT_RESOURCE_L3CODE) + pair_type = VIR_RDT_RESOURCE_L3DATA; + for (i = 1; i < domainall.num_domains; i ++) { schemata_sum |= p->schematas[type]->schemata_items[sid].schemata; + if (pair_type > 0) + schemata_sum |= p->schematas[pair_type]->schemata_items[sid].schemata; p = p->next; } @@ -752,6 +773,9 @@ int virResCtrlSetCacheBanks(virDomainCachetunePtr cachetune, } if (p != NULL) { + + virResCtrlAppendDomain(p); + for (i = 0; i < cachetune->n_banks; i++) { if ((type = virResCtrlTypeFromString( cachetune->cache_banks[i].type)) < 0) { @@ -786,7 +810,6 @@ int virResCtrlSetCacheBanks(virDomainCachetunePtr cachetune, virResCtrlDestroyDomain(p); return -1; } - virResCtrlAppendDomain(p); } else { VIR_ERROR(_("Failed to create a domain in sysfs")); return -1; -- 1.9.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list