Description
I have looked at the test code, and have a doubt on the test's design.
If I understand it correctly, the test creates VMs and put the vcpu threads of these VMs into cgroups so that they can use as much as the max capability of all host cpus. Then it starts a number of while-loops in each VM to use up that capability. Then it checks if the cpu time used by guest is close to that used by host.
My question is about the setup. The test sets up cgroups to allow VMs use up all host cpu cores (implementation details: assuming host has 40 cores, the test creates VMs with total number of 80 vcpus, and allow each vcpu thread to use 0.5 core in term of cpu time. So in total it allows these VMs to use all cpu time on the host). From my understanding, when one verifies cgroup setup, one should check the actual resource usage doesn't exceed the limit. In this case, however, since the limit is the entire host cpu time, I wonder how it can be checked? Or let me put it this way, if we remove the cgroup setup in this test, the test would still have same result, doesn't it? (I think so, thought I didn't verify it).
In my opinion, the test should be changed to set up cgroups to allow all VMs can use, say, 50% of host cpu time. Then run workload (eg., the while-loop) in VMs and check it doesn't exceed the limit by using the data in /proc/stat.