Skip to contentSkip to conversation

tests.cgroup: Add CpuShare test

kvm-autotest New Lukas Doktor 1 participant 2 messages Nov 28, 2011 KVM

lore
Share & tools
lore
#0 lore raw

Hi guys,

I have a new kvm cgroup test for you.

This time it's in cpu cgroup and it uses cpu.shares capability. It modifies the number of shares/time_slices which each process gets from the scheduler As the verification is kind of tricky I'm testing only three different scenerios and only symetrical solutions:

1) #threads == #CPUs
2) #threads + 1 == #CPUs, +1thread have the lowest priority (or equal)
3) #threads * #cgroups == #CPUs

ad1) When less threads are occupied, the utilisation should be equal. ad2) When there is +1 thread with lower priority, it fight with the
second thread from the lowest priority group, thus the utilisations are still equal. If you try it other way around (higher utilisation) this current thread forces the utilisation in cgroups ratios. This is not tested as it would be trickier with multiple cgroups/threads
ad3) When each cgroup have multiple threads it can fight for it's share
thus in the end they all should settle on cgroup ratio utilisations.

To minimalize system impact I'm using 10-100times bigger slices/priority then other processes. Still when are you running other processes on the system the test might fail. Keep in mind it should run on clean test machine.

Anyway, be my guests at github pull request:
https://github.com/autotest/autotest/pull/94

Regards,
Lukáš Doktor

#1 lore raw

PATCH 1/1 tests.cgroup: Add CpuShare test

* Adds base _TestCpuShare
* Adds TestCpuShare10 - cpu.shares ratio is 1:10
* Adds TestCpuShare50 - cpu.shares ratio is 1:1
* cgroup_common - incorrect lookup for mounted cgroups
* kvm cgroup - sort the executed tests (per expression)
* minor bugfixies

Tests the cpu.share cgroup capability. It creates n cgroups accordingly to self.speeds variable and sufficient VMs to symetricaly test three different scenerios:

1) #threads == #CPUs
2) #threads + 1 == #CPUs, +1thread have the lowest priority (or equal)
3) #threads * #cgroups == #CPUs

Scheduler shouldn't slow down VMs on unoccupied CPUs. With thread overcommit the scheduler should stabilize accordingly to speeds value.

---
 client/tests/cgroup/cgroup_common.py |    8 +-
 client/tests/kvm/tests/cgroup.py     |  258 +++++++++++++++++++++++++++++++++-
 2 files changed, 260 insertions(+), 6 deletions(-)
client/tests/cgroup/cgroup_common.py +5 -3
index 7d5daf2..95b0e61 100755
@@ -201,6 +201,8 @@ class Cgroup(object):
         value = str(value)
         if pwd == None:
             pwd = self.root
+        if isinstance(pwd, int):
+            pwd = self.cgroups[pwd]
         try:
             open(pwd+prop, 'w').write(value)
         except Exception, inst:
@@ -280,8 +282,8 @@ class CgroupModules(object):
                 try:
                     utils.system('umount %s -l' % self.modules[1][i])
                 except Exception, failure_detail:
-                    logging.warn("CGM: Couldn't unmount %s directory: %s"
-                                 % (self.modules[1][i], failure_detail))
+                    logging.warn("CGM: Couldn't unmount %s directory: %s",
+                                 self.modules[1][i], failure_detail)
         try:
             shutil.rmtree(self.mountdir)
         except Exception:
@@ -308,7 +310,7 @@ class CgroupModules(object):
             # Is it already mounted?
             i = False
             for mount in mounts:
-                if mount[3].find(module) != -1:
+                if  module in mount[3].split(','):
                     self.modules[0].append(module)
                     self.modules[1].append(mount[1] + '/')
                     self.modules[2].append(False)
client/tests/kvm/tests/cgroup.py +255 -3

290 lines not on this page · raw message

Signature · 1 line
1.7.7.3