]> xenbits.xensource.com Git - libvirt.git/commitdiff
resctrl: Don't assume MBA availability in virResctrlAllocNewFromInfo
authorMartin Kletzander <mkletzan@redhat.com>
Wed, 11 Sep 2024 13:06:04 +0000 (15:06 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Fri, 13 Sep 2024 10:55:39 +0000 (12:55 +0200)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virresctrl.c
tests/virresctrldata/resctrl.schemata

index 30695092a1689d03e8520a61799ee62d39bb1e6c..f3ec4d67059fa375fdc43fdfe0dc933be50b4eed 100644 (file)
@@ -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)
index 2578822b709dff17b1d6f73439738ae3f3e9c927..fa980e58c9dd2b6d7d2fbb0ad4762f8a998dc7c2 100644 (file)
@@ -1,2 +1 @@
 L3:0=000ff;1=000f0
-MB:0=100;1=100