Bug 727458

Summary: cpu.share doesn't limit the cpu usage
Product: Red Hat Enterprise Linux 6 Reporter: Suqin Huang <shuang>
Component: kernelAssignee: Jacob Tanenbaum <jtanenba>
Status: CLOSED NOTABUG QA Contact: Red Hat Kernel QE team <kernel-qe>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: dhoward, qcai, shuang, sluo
Target Milestone: rcFlags: jtanenba: needinfo? (shuang)
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 918395 (view as bug list) Environment:
Last Closed: 2014-03-19 18:00:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 918395    

Description Suqin Huang 2011-08-02 08:13:13 UTC
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:
100%

Steps to Reproduce:
1. create cgroups
# mount -t cgroup -o cpu none /cgroup
# mkdir /cgroup/cpu1
# mkdir /cgroup/cpu2

2. set cpu.share for each cgroup
# ech0 1024 > /cgroup/cpu1/cpu.share
# echo 2048 > /cgroup/cpu2/cpu.share

3. boot two guests (both with 2 vcpu)

4. echo pidof-guest1 to > /cgroup/cpu1/tasks (contain threads)
5. echo pidof-guest2 to > /cgroup/cpu2/tasks (contain threads)
6. run the following script in guests:

#include <stdio.h>

int main(void){
        int i;

        for(;;){
                i += 1;
        }

        return 0;
}

  
guest1: run 3 tasks with above script
guest2: run 1 tasks with above script

Actual results:
cpu usage: guest1 vs. guest2 : 300% vs. 100%

Expected results:
cpu usage: guest1 vs. guest2 : 50% vs. 100%

Additional info:

Comment 4 Sibiao Luo 2013-03-06 07:23:51 UTC
Hi all,

   I tried the kernel-2.6.32-356.el6.x86_64, but still hit this issue, the cpu.shares fail to limit the cpu usage correctly. btw, i also hit it in rhel7 host, i will clone it to rhel7.

host info:
kernel-2.6.32-356.el6.x86_64
qemu-kvm-0.12.1.2-2.358.el6.x86_64

guest info:
kernel-2.6.32-356.el6.x86_64

Steps:
the same to comment #0.
# echo 1024 > /cgroup/cpu1/cpu.shares 
# echo 2048 > /cgroup/cpu2/cpu.shares 
both two guests with 2 vcpu.

Results:
The cpu usage: guest1 vs. guest2 : 200% vs. 100%
# top
...
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                        
13865 root      20   0 2586m 602m 4540 S 199.4  7.7   4:06.69 qemu-kvm <--guest1                                                                                                      
13888 root      20   0 2559m 603m 4540 S 99.4   7.7   3:09.15 qemu-kvm <--guest2


If run 2 tasks with above script in each guest, the cpu usage: guest1 vs. guest2 : 200% vs. 200%
# top
  PID USER     PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                        
13865 root     20   0 2586m 602m 4540 S 199.7  7.7   1:57.07 qemu-kvm  <--guest1                                                                                                     
13888 root     20   0 2559m 602m 4540 S 199.7  7.7   1:41.49 qemu-kvm  <--guest2

Best Regards.
sluo

Comment 7 RHEL Program Management 2013-10-14 05:15:35 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 9 Jacob Tanenbaum 2014-03-19 18:00:00 UTC
It appears that in the absence of additional information cpu.share is acting as it should. Additionally the customer bug attached has been closed