[PATCH 09/10] qemu: Introduce resctrl monitoring group

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

 



Resource monitoring group monitors the resource consumption, cache and
memory bandwidth, of particular resctrl allocation. Introduce the resctrl
monitoring group.

Signed-off-by: Wang Huaqiang <huaqiang.wang@xxxxxxxxx>
---
 src/qemu/qemu_process.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 960c3ed..e70aa5e 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2593,6 +2593,7 @@ qemuProcessResctrlCreate(virQEMUDriverPtr driver,
 {
     int ret = -1;
     size_t i = 0;
+    size_t j = 0;
     virCapsPtr caps = NULL;
     qemuDomainObjPrivatePtr priv = vm->privateData;
 
@@ -2610,6 +2611,20 @@ qemuProcessResctrlCreate(virQEMUDriverPtr driver,
                                   vm->def->resctrls[i]->alloc,
                                   priv->machineName) < 0)
             goto cleanup;
+
+        /* Create resctrl monitoring groups associated with allocation */
+        for (j = 0; j < vm->def->resctrls[i]->nmonitors; j++) {
+            virDomainResctrlMonitorPtr monitor = NULL;
+            monitor = vm->def->resctrls[i]->monitors[j];
+
+            if (virResctrlAllocCreateMonitor(caps->host.resctrl,
+                                             vm->def->resctrls[i]->alloc,
+                                             priv->machineName,
+                                             monitor->id) < 0)
+
+                goto cleanup;
+
+        }
     }
 
     ret = 0;
@@ -5419,7 +5434,9 @@ qemuProcessSetupVcpu(virDomainObjPtr vm,
 {
     pid_t vcpupid = qemuDomainGetVcpuPid(vm, vcpuid);
     virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, vcpuid);
+    virDomainResctrlMonitorPtr mon = NULL;
     size_t i = 0;
+    size_t j = 0;
 
     if (qemuProcessSetupPid(vm, vcpupid, VIR_CGROUP_THREAD_VCPU,
                             vcpuid, vcpu->cpumask,
@@ -5434,7 +5451,15 @@ qemuProcessSetupVcpu(virDomainObjPtr vm,
         if (virBitmapIsBitSet(ct->vcpus, vcpuid)) {
             if (virResctrlAllocAddPID(ct->alloc, vcpupid) < 0)
                 return -1;
-            break;
+        }
+
+        for (j = 0; j < vm->def->resctrls[i]->nmonitors; j++) {
+            mon = vm->def->resctrls[i]->monitors[j];
+            if (virBitmapIsBitSet(mon->vcpus, vcpuid)) {
+                if (virResctrlAllocAddMonitorPID(ct->alloc,
+                                                 mon->id, vcpupid) < 0)
+                    return -1;
+            }
         }
     }
 
@@ -7747,10 +7772,12 @@ qemuProcessReconnect(void *opaque)
     int reason;
     virQEMUDriverConfigPtr cfg;
     size_t i;
+    size_t j;
     unsigned int stopFlags = 0;
     bool jobStarted = false;
     virCapsPtr caps = NULL;
     bool retry = true;
+    virDomainResctrlDefPtr resctrl = NULL;
 
     VIR_FREE(data);
 
@@ -7934,9 +7961,18 @@ qemuProcessReconnect(void *opaque)
         goto error;
 
     for (i = 0; i < obj->def->nresctrls; i++) {
-        if (virResctrlAllocDeterminePath(obj->def->resctrls[i]->alloc,
+        resctrl = obj->def->resctrls[i];
+
+        if (virResctrlAllocDeterminePath(resctrl->alloc,
                                          priv->machineName) < 0)
             goto error;
+
+        for (j = 0; j < resctrl->nmonitors; j++) {
+            if (virResctrlAllocDetermineMonitorPath(resctrl->alloc,
+                                                    resctrl->monitors[j]->id,
+                                                    priv->machineName) < 0)
+                goto error;
+        }
     }
 
     /* update domain state XML with possibly updated state in virDomainObj */
-- 
2.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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