mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
resctrl: Don't assume MBA availability in virResctrlAllocNewFromInfo
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>
This commit is contained in:
parent
bc97a2c043
commit
f3fd0664cf
@ -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)
|
||||
|
@ -1,2 +1 @@
|
||||
L3:0=000ff;1=000f0
|
||||
MB:0=100;1=100
|
||||
|
Loading…
Reference in New Issue
Block a user