[v5 6/9] Resctrl: enable l3code/l3data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 0d400a9..bdf922d 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -557,6 +557,7 @@ int virResCtrlRefreshSchemata(void)
     size_t i, j, k;
     unsigned int tmp_schemata;
     unsigned int default_schemata;
+    int pair_type = 0;
 
     virResDomainPtr header, p;
 
@@ -567,6 +568,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);
@@ -574,6 +581,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 */
@@ -685,6 +694,7 @@ virResCtrlWrite(const char *name, const char *item, const char *content)
         goto cleanup;
 
     rc = 0;
+
  cleanup:
     VIR_FREE(path);
     VIR_FORCE_CLOSE(writefd);
@@ -888,6 +898,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);
@@ -902,8 +913,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;
     }
 
@@ -944,6 +965,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) {
@@ -978,7 +1002,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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux