}
-static void
-virResctrlMemoryBandwidthSubtract(virResctrlAllocPtr free,
- virResctrlAllocPtr used)
-{
- size_t i;
-
- if (!used->mem_bw)
- return;
-
- for (i = 0; i < used->mem_bw->nbandwidths; i++) {
- if (used->mem_bw->bandwidths[i])
- *(free->mem_bw->bandwidths[i]) -= *(used->mem_bw->bandwidths[i]);
- }
-}
-
-
static virResctrlAllocPtr
virResctrlAllocNewFromInfo(virResctrlInfoPtr info)
{
}
/*
- * This function creates an allocation that represents all unused parts of
- * all caches and memory bandwidth in the system. It uses virResctrlInfo
- * for creating a new full allocation with all bits set (using the
- * virResctrlAllocNewFromInfo()), sets memory bandwidth 100%, and then scans
- * for all allocations under /sys/fs/resctrl and subtracts each one of them
- * from it. That way it can then return an allocation with only bit set
- * being those that are not mentioned in any other allocation for CAT and
- * available memory bandwidth for MBA. It is used for two things, calculating
- * the masks and bandwidth available when creating allocations and from tests.
+ * This function creates an allocation that represents all unused parts of all
+ * caches in the system. It uses virResctrlInfo for creating a new full
+ * allocation with all bits set (using virResctrlAllocNewFromInfo()) and then
+ * scans for all allocations under /sys/fs/resctrl and subtracts each one of
+ * them from it. That way it can then return an allocation with only bit set
+ * being those that are not mentioned in any other allocation. It is used for
+ * two things, a) calculating the masks when creating allocations and b) from
+ * tests.
+ *
+ * MBA (Memory Bandwidth Allocation) is not taken into account as it is a
+ * limiting setting, not an allocating one. The way it works is also vastly
+ * different from CAT.
*/
virResctrlAllocPtr
virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
goto error;
}
- virResctrlMemoryBandwidthSubtract(ret, alloc);
virResctrlAllocSubtract(ret, alloc);
virObjectUnref(alloc);
alloc = NULL;
static int
virResctrlAllocMemoryBandwidth(virResctrlInfoPtr resctrl,
- virResctrlAllocPtr alloc,
- virResctrlAllocPtr free)
+ virResctrlAllocPtr alloc)
{
size_t i;
virResctrlAllocMemBWPtr mem_bw_alloc = alloc->mem_bw;
- virResctrlAllocMemBWPtr mem_bw_free = free->mem_bw;
virResctrlInfoMemBWPtr mem_bw_info = resctrl->membw_info;
if (!mem_bw_alloc)
i, mem_bw_info->max_id);
return -1;
}
- if (*(mem_bw_alloc->bandwidths[i]) > *(mem_bw_free->bandwidths[i])) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Not enough room for allocation of %u%% "
- "bandwidth on node %zd, available bandwidth %u%%"),
- *(mem_bw_alloc->bandwidths[i]), i,
- *(mem_bw_free->bandwidths[i]));
- return -1;
- }
}
return 0;
}
if (!alloc_default)
goto cleanup;
- if (virResctrlAllocMemoryBandwidth(resctrl, alloc, alloc_free) < 0)
+ if (virResctrlAllocMemoryBandwidth(resctrl, alloc) < 0)
goto cleanup;
if (virResctrlAllocCopyMasks(alloc, alloc_default) < 0)