[PATCH 08/10] resctrl: Don't assume MBA availability in virResctrlAllocNewFromInfo

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

 



Weirdly, the existence of /sys/fs/resctrl/info/MB does not always mean
that MBA is available and used on the system.  Instead of assuming that
copy the values from the default (root) allocation.  This also makes it
nicer to use the proper values in case the system does not use
percentages or when the root allocation already limits the bandwidth.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/util/virresctrl.c                 | 16 +++-------------
 tests/virresctrldata/resctrl.schemata |  1 -
 2 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index 30695092a168..f3ec4d67059f 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -1805,19 +1805,6 @@ virResctrlAllocNewFromInfo(virResctrlInfo *info)
         }
     }
 
-    /* set default free memory bandwidth to 100% */
-    if (info->membw_info) {
-        ret->mem_bw = g_new0(virResctrlAllocMemBW, 1);
-
-        VIR_EXPAND_N(ret->mem_bw->bandwidths, ret->mem_bw->nbandwidths,
-                     info->membw_info->max_id + 1);
-
-        for (i = 0; i < ret->mem_bw->nbandwidths; i++) {
-            ret->mem_bw->bandwidths[i] = g_new0(unsigned int, 1);
-            *(ret->mem_bw->bandwidths[i]) = 100;
-        }
-    }
-
     return g_steal_pointer(&ret);
 }
 
@@ -1890,6 +1877,9 @@ virResctrlAllocGetUnused(virResctrlInfo *resctrl)
     if (!alloc_default)
         return NULL;
 
+    /* Take MBA maximums from the root allocation */
+    virResctrlAllocCopyMemBW(ret, alloc_default);
+
     virResctrlAllocSubtract(ret, alloc_default);
 
     if (virDirOpen(&dirp, SYSFS_RESCTRL_PATH) < 0)
diff --git a/tests/virresctrldata/resctrl.schemata b/tests/virresctrldata/resctrl.schemata
index 2578822b709d..fa980e58c9dd 100644
--- a/tests/virresctrldata/resctrl.schemata
+++ b/tests/virresctrldata/resctrl.schemata
@@ -1,2 +1 @@
 L3:0=000ff;1=000f0
-MB:0=100;1=100
-- 
2.46.0




[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