render / rpms / libvirt

Forked from rpms/libvirt 7 months ago
Clone
99cbc7
From bef145fd9b22a310ce7ab8e4cd033bcbe9d40fa9 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <bef145fd9b22a310ce7ab8e4cd033bcbe9d40fa9@dist-git>
99cbc7
From: Martin Kletzander <mkletzan@redhat.com>
99cbc7
Date: Mon, 15 Apr 2019 17:33:02 +0200
99cbc7
Subject: [PATCH] resctrl: Do not calculate free bandwidth for MBA
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
For CAT we calculate unallocated parts of the cache, however with MBA this does
99cbc7
not make sense as the purpose of that is to limit the bandwidth and the setting
99cbc7
is only proportional relative to bandwidth settings for other groups.
99cbc7
99cbc7
This means it makes sense to set the values to 100% even if there are other
99cbc7
groups with some allocations and that we don't need to find the available
99cbc7
(unallocated) bandwidth in all the groups.
99cbc7
99cbc7
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
99cbc7
(cherry picked from commit 408aeebcef1e81e55bebb4f2d47403d04ee16c0f)
99cbc7
99cbc7
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1468650
99cbc7
99cbc7
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
99cbc7
Message-Id: <75b61f0528c91997bf86e6e65b6f4673bad44d75.1555342313.git.phrdina@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/util/virresctrl.c | 52 ++++++++++++-------------------------------
99cbc7
 1 file changed, 14 insertions(+), 38 deletions(-)
99cbc7
99cbc7
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
99cbc7
index 4b5442f879..f5e4bef7dc 100644
99cbc7
--- a/src/util/virresctrl.c
99cbc7
+++ b/src/util/virresctrl.c
99cbc7
@@ -1509,22 +1509,6 @@ virResctrlAllocSubtract(virResctrlAllocPtr dst,
99cbc7
 }
99cbc7
 
99cbc7
 
99cbc7
-static void
99cbc7
-virResctrlMemoryBandwidthSubtract(virResctrlAllocPtr free,
99cbc7
-                                  virResctrlAllocPtr used)
99cbc7
-{
99cbc7
-    size_t i;
99cbc7
-
99cbc7
-    if (!used->mem_bw)
99cbc7
-        return;
99cbc7
-
99cbc7
-    for (i = 0; i < used->mem_bw->nbandwidths; i++) {
99cbc7
-        if (used->mem_bw->bandwidths[i])
99cbc7
-            *(free->mem_bw->bandwidths[i]) -= *(used->mem_bw->bandwidths[i]);
99cbc7
-    }
99cbc7
-}
99cbc7
-
99cbc7
-
99cbc7
 static virResctrlAllocPtr
99cbc7
 virResctrlAllocNewFromInfo(virResctrlInfoPtr info)
99cbc7
 {
99cbc7
@@ -1588,15 +1572,18 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr info)
99cbc7
 }
99cbc7
 
99cbc7
 /*
99cbc7
- * This function creates an allocation that represents all unused parts of
99cbc7
- * all caches and memory bandwidth in the system. It uses virResctrlInfo
99cbc7
- * for creating a new full allocation with all bits set (using the
99cbc7
- * virResctrlAllocNewFromInfo()), sets memory bandwidth 100%, and then scans
99cbc7
- * for all allocations under /sys/fs/resctrl and subtracts each one of them
99cbc7
- * from it. That way it can then return an allocation with only bit set
99cbc7
- * being those that are not mentioned in any other allocation for CAT and
99cbc7
- * available memory bandwidth for MBA. It is used for two things, calculating
99cbc7
- * the masks and bandwidth available when creating allocations and from tests.
99cbc7
+ * This function creates an allocation that represents all unused parts of all
99cbc7
+ * caches in the system.  It uses virResctrlInfo for creating a new full
99cbc7
+ * allocation with all bits set (using virResctrlAllocNewFromInfo()) and then
99cbc7
+ * scans for all allocations under /sys/fs/resctrl and subtracts each one of
99cbc7
+ * them from it.  That way it can then return an allocation with only bit set
99cbc7
+ * being those that are not mentioned in any other allocation.  It is used for
99cbc7
+ * two things, a) calculating the masks when creating allocations and b) from
99cbc7
+ * tests.
99cbc7
+ *
99cbc7
+ * MBA (Memory Bandwidth Allocation) is not taken into account as it is a
99cbc7
+ * limiting setting, not an allocating one.  The way it works is also vastly
99cbc7
+ * different from CAT.
99cbc7
  */
99cbc7
 virResctrlAllocPtr
99cbc7
 virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
99cbc7
@@ -1642,7 +1629,6 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
99cbc7
             goto error;
99cbc7
         }
99cbc7
 
99cbc7
-        virResctrlMemoryBandwidthSubtract(ret, alloc);
99cbc7
         virResctrlAllocSubtract(ret, alloc);
99cbc7
         virObjectUnref(alloc);
99cbc7
         alloc = NULL;
99cbc7
@@ -1795,12 +1781,10 @@ virResctrlAllocFindUnused(virResctrlAllocPtr alloc,
99cbc7
 
99cbc7
 static int
99cbc7
 virResctrlAllocMemoryBandwidth(virResctrlInfoPtr resctrl,
99cbc7
-                               virResctrlAllocPtr alloc,
99cbc7
-                               virResctrlAllocPtr free)
99cbc7
+                               virResctrlAllocPtr alloc)
99cbc7
 {
99cbc7
     size_t i;
99cbc7
     virResctrlAllocMemBWPtr mem_bw_alloc = alloc->mem_bw;
99cbc7
-    virResctrlAllocMemBWPtr mem_bw_free = free->mem_bw;
99cbc7
     virResctrlInfoMemBWPtr mem_bw_info = resctrl->membw_info;
99cbc7
 
99cbc7
     if (!mem_bw_alloc)
99cbc7
@@ -1840,14 +1824,6 @@ virResctrlAllocMemoryBandwidth(virResctrlInfoPtr resctrl,
99cbc7
                            i, mem_bw_info->max_id);
99cbc7
             return -1;
99cbc7
         }
99cbc7
-        if (*(mem_bw_alloc->bandwidths[i]) > *(mem_bw_free->bandwidths[i])) {
99cbc7
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
99cbc7
-                           _("Not enough room for allocation of %u%% "
99cbc7
-                             "bandwidth on node %zd, available bandwidth %u%%"),
99cbc7
-                           *(mem_bw_alloc->bandwidths[i]), i,
99cbc7
-                           *(mem_bw_free->bandwidths[i]));
99cbc7
-            return -1;
99cbc7
-        }
99cbc7
     }
99cbc7
     return 0;
99cbc7
 }
99cbc7
@@ -1914,7 +1890,7 @@ virResctrlAllocAssign(virResctrlInfoPtr resctrl,
99cbc7
     if (!alloc_default)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
-    if (virResctrlAllocMemoryBandwidth(resctrl, alloc, alloc_free) < 0)
99cbc7
+    if (virResctrlAllocMemoryBandwidth(resctrl, alloc) < 0)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
     if (virResctrlAllocCopyMasks(alloc, alloc_default) < 0)
99cbc7
-- 
99cbc7
2.21.0
99cbc7