[PATCH resend V10 06/12] 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         | 27 +++++++++++++++++++++++++--
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index efc84c5..ed8bdb9 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5528,7 +5528,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 43af0f5..e7376a0 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -417,6 +417,7 @@ int virResCtrlRefreshSchemata(void)
     unsigned int tmp_schemata;
     unsigned int default_schemata;
     unsigned int min_schemata;
+    int pair_type = 0;
 
     virResDomainPtr header, p;
 
@@ -429,6 +430,11 @@ int virResCtrlRefreshSchemata(void)
         if (VIR_RESCTRL_ENABLED(i)) {
             min_schemata = VIR_RESCTRL_GET_SCHEMATA(resctrlall[i].min_cbm_bits);
 
+            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;
                 // Reset to default schemata 0xfffff
@@ -436,8 +442,11 @@ int virResCtrlRefreshSchemata(void)
                 tmp_schemata = 0;
                 /* NOTEs: if only header domain, the schemata will be set to default one*/
                 for (k = 1; k < domainall.num_domains; k++) {
-                    if (p->schematas[i]->schemata_items[j].schemata > min_schemata)
+                    if (p->schematas[i]->schemata_items[j].schemata > min_schemata) {
                         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;
                 }
 
@@ -503,6 +512,7 @@ virResCtrlWrite(const char *name, const char *item, const char *content)
         goto cleanup;
 
     rc = 0;
+
  cleanup:
     VIR_FREE(path);
     VIR_FORCE_CLOSE(writefd);
@@ -707,6 +717,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);
@@ -721,8 +732,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;
     }
 
@@ -763,6 +784,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) {
@@ -797,7 +821,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