tests.cgroup: Add cpu_cfs test and bugfixes
Hi guys,
Please find the cpu_cfs_util test which tests the usage of CFS scheduler when cpu.cfs_quota_us is set. It start-ups enough VMs to overcome twice all host's CPUs and sets 50% quota for each process. In theory the utilisation should be exactly 100%. We measure the difference between all host-times and guest times (/proc/stat). The utilisation should be over 95%. (turn off your Firefox, movie players and Thunderbirds if you are running it directly on your box ;-) )
The second patch contains minor changes and bugfixes.
See the pull request:
https://github.com/autotest/autotest/pull/120
Best regards and merry Christmas,
Lukáš Doktor
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
PATCH 1/2 tests.cgroup: Add cpu_cfs_util test
This test tests the cpu.cfs_* subsystem. It's focused on known issue with multiple threads in related cpu cgroup with defined cpu.cfs_quota_us. CFS might schedule those threads very inefficiently.
* Add TestCpuCFS
--- client/tests/kvm/subtests.cfg.sample | 2 + client/tests/kvm/tests/cgroup.py | 168 ++++++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+), 0 deletions(-)
client/tests/kvm/subtests.cfg.sample +2 -0
@@ -1048,6 +1048,8 @@ variants: type = cgroup # cgroup_tests = "re1[:loops] re2[:loops] ..." cgroup_tests = ".*:1" + #cgroup_memory_limit_kb = 2097152 # default 1/2 guest ram + #cgroup_memory_move_mb = 2048 # default 1/2 guest ram vms += " vm2" extra_params += " -snapshot"
client/tests/kvm/tests/cgroup.py +168 -0
180 lines not on this page · raw message
Signature · 1 line
1.7.7.4
PATCH 2/2 tests.cgroup: Variable limits in TestMemory* and bugfixes
In reply to Lukas Doktor* Add cgroup_memory_limit_kb, cgroup_memory_move_mb variables into cfg to allow user specify the amount of tested/stressed memory
* Use iflag=fullblock to force allocate the full blocks in dd
* FIX cpu enumeration in cpuset subtest
--- client/tests/kvm/tests/cgroup.py | 36 ++++++++++++++++++++++++------------ 1 files changed, 24 insertions(+), 12 deletions(-)
client/tests/kvm/tests/cgroup.py +24 -12
@@ -945,8 +945,13 @@ def run_cgroup(test, params, env): sessions.append(self.vm.wait_for_login(timeout=30)) sessions.append(self.vm.wait_for_login(timeout=30)) - size = int(params.get('mem', 512)) / 2 # Use half of the memory - sessions[0].sendline('dd if=/dev/zero of=/dev/null bs=%sM' % size) + # Don't allow to specify more than 1/2 of the VM's memory + size = int(params.get('mem', 1024)) / 2 + if params.get('cgroup_memory_move_mb') is not None: + size = min(size, int(params.get('cgroup_memory_move_mb'))) + + sessions[0].sendline('dd if=/dev/zero of=/dev/null bs=%dM ' + 'iflag=fullblock' % size) time.sleep(2) sessions[1].cmd('killall -SIGUSR1 dd')
@@ -975,7 +980,7 @@ def run_cgroup(test, params, env): (dd_res[0], dd_res[1], dd_res[2], dd_res[3])) - return ("Memory move succeeded") + return ("Guest moved 10times while creating %dMB blocks" % size) class TestMemoryLimit:
@@ -1009,13 +1014,16 @@ def run_cgroup(test, params, env): """ Initialization: prepares the cgroup and starts new VM inside it. """ - # Use half of the VM's memory (in KB) - mem = int(int(params.get('mem', 1024)) * 512) + # Don't allow to specify more than 1/2 of the VM's memory + mem = int(params.get('mem', 1024)) * 512 + if params.get('cgroup_memory_limit_kb') is not None: + mem = min(mem, int(params.get('cgroup_memory_limit_kb'))) + self.cgroup.initialize(self.modules) self.cgroup.mk_cgroup() self.cgroup.set_property('memory.move_charge_at_immigrate', '3', self.cgroup.cgroups[0]) - self.cgroup.set_property_h('memory.limit_in_bytes', "%sK" % mem, + self.cgroup.set_property_h('memory.limit_in_bytes', "%dK" % mem, self.cgroup.cgroups[0]) logging.info("Expected VM reload")
@@ -1040,9 +1048,13 @@ def run_cgroup(test, params, env): """ session = self.vm.wait_for_login(timeout=30) - # Convert into KB, use 0.6 * guest memory (== * 614.4) - mem = int(int(params.get('mem', 1024)) * 615) - session.sendline('dd if=/dev/zero of=/dev/null bs=%sK count=1' %mem) + # Use 1.1 * memory_limit block size + mem = int(params.get('mem', 1024)) * 512 + if params.get('cgroup_memory_limit_kb') is not None: + mem = min(mem, int(params.get('cgroup_memory_limit_kb'))) + mem *= 1.1 + session.sendline('dd if=/dev/zero of=/dev/null bs=%dK count=1 ' + 'iflag=fullblock' %mem) # Check every 0.1s VM memory usage. Limit the maximum execution time # to mem / 10 (== mem * 0.1 sleeps)
@@ -1077,7 +1089,7 @@ def run_cgroup(test, params, env): raise error.TestFail("VM didn't consume expected amount of " "memory. Output of dd cmd: %s" % out) - return ("Limits were enforced successfully.") + return ("Created %dMB block with 1.1 limit overcommit" % (mem/1024)) class _TestCpuShare(object):
@@ -1599,8 +1611,8 @@ def run_cgroup(test, params, env): # CPUs: O_O_, Stat: 200 cpus = "0" - for i in range(2, min(vm_cpus*2, no_cpus)): - cpus += ",%d" % i*2 + for i in range(1, min(vm_cpus, (no_cpus/2))): + cpus += ",%d" % (i*2) self.cgroup.set_property('cpuset.cpus', cpus, 0) stats.append((_test_it(tst_time), cpus))
Signature · 1 line
1.7.7.4