Change in vdsm[master]: Fix the CPU quota MOM policy computations

msivak at redhat.com msivak at redhat.com
Tue Mar 31 15:31:39 UTC 2015


Martin Sivák has uploaded a new change for review.

Change subject: Fix the CPU quota MOM policy computations
......................................................................

Fix the CPU quota MOM policy computations

This changes the way we compute period and quota to what
is described in the documentation:

The maximum CPU load percentage is related to the total computing
power the host has.

Two issues are also fixed by this:

- the period could get below 1000 with low enough percentage
  or high enough vCPU count and libvirt won't accept that

- the quota number was higher than period when vCPU count was
  lower than the number of physical CPUs, effectively disabling
  the CPU limits

Change-Id: Ia1f014d1b4058ef447a962cbda3336115e8610dc
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1207610
Signed-off-by: Martin Sivak <msivak at redhat.com>
---
M vdsm/mom.d/04-cputune.policy
1 file changed, 26 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/11/39411/1

diff --git a/vdsm/mom.d/04-cputune.policy b/vdsm/mom.d/04-cputune.policy
index 75ae9c9..afdab23 100644
--- a/vdsm/mom.d/04-cputune.policy
+++ b/vdsm/mom.d/04-cputune.policy
@@ -1,23 +1,42 @@
 ### Auto-CpuTune ###############################################################
 
-(defvar anchor 100000)
+# Default quota turns off the CPU limits
 (defvar defaultQuota -1)
-(defvar defaultPeriod 1000)
 
-(defvar calcPeriod  (/ anchor Host.cpu_count))
+# The default measurement period in us -> 100ms
+(defvar defaultPeriod 100000)
+
 
 ### Helper functions
 (def check_and_set_quota (guest)
 {
+    # The maximum amount of CPU time the VM can use in total
+    # = Measuring interval * number of physical CPUs * Maximum load
+    #
+    # Maximum load is expressed as a percent of the total processing
+    # capability available to the host (RHEV Admin guide 10.5.7)
+    (defvar maxCpuTime (* (/ guest.vcpu_user_limit 100.0) (* defaultPeriod Host.cpu_count)))
 
-    (defvar calcQuota (/ (* anchor (/ guest.vcpu_user_limit 100.0)) guest.vcpu_count))
+    # Distribute the allocated time between the configured vCPUs
+    (defvar calcQuota (/ maxCpuTime guest.vcpu_count)
+
+    # Time amount multiplier, default is 1 = use the computed values
+    # Higher values are used when low percentages or high amount of vCPUs cause
+    # the calcQuota to get below the allowed limit of 1000. This slows down
+    # the reaction time, but allows enough time to measure such small load
+    # percentages (and makes libvirt happy)
+    (if (> calcQuota 1000) {
+        (defvar timeMultiplier 1)
+    } {
+        (defvar timeMultiplier 1 + (/ 1000 calcQuota))
+    })
+
+    (set calcQuota (* timeMultiplier calcQuota))
+    (set calcPeriod (* timeMultiplier calcPeriod))
 
     (if (!= guest.vcpu_quota calcQuota)
         (guest.Control "vcpu_quota" calcQuota) 0)
-})
 
-(def check_and_set_period (guest)
-{
     (if (!= guest.vcpu_period calcPeriod)
         (guest.Control "vcpu_period" calcPeriod) 0)
 })
@@ -41,7 +60,6 @@
 
 (if (== True cpuTuneEnabled) {
     (with Guests guest (check_and_set_quota guest))
-    (with Guests guest (check_and_set_period guest))
 } {
     (with Guests guest (reset_quota_and_period guest))
 })


-- 
To view, visit https://gerrit.ovirt.org/39411
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia1f014d1b4058ef447a962cbda3336115e8610dc
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Sivák <msivak at redhat.com>


More information about the vdsm-patches mailing list