Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1244128 - Setvcpu should inherit the cputune value in cgroups was set before via schedinfo
Setvcpu should inherit the cputune value in cgroups was set before via schedinfo
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.2
x86_64 Unspecified
medium Severity medium
: rc
: ---
Assigned To: Peter Krempa
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-07-17 04:53 EDT by Pei Zhang
Modified: 2016-11-03 14:19 EDT (History)
6 users (show)

See Also:
Fixed In Version: libvirt-1.3.2-1.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-11-03 14:19:53 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2577 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2016-11-03 08:07:06 EDT

  None (edit)
Description Pei Zhang 2015-07-17 04:53:38 EDT
Description of problem:
when I use command "setvcpu" to change the vcpus of a guest, I think the new vcpus should also inherit the cputune value I set for vcpu before .
because I don't think I can set new cputune value for each vcpu in cgroups(via virsh command ) or domain xml .
If I use setvcpu first , then the cputune value was set via schedinfo will be set into each vcpu in cgroups .

Version-Release number of selected component (if applicable):
libvirt-1.2.17-2.el7.x86_64
qemu-kvm-rhev-2.3.0-10.el7.x86_64

How reproducible:
100%

Steps to Reproduce:

1.define and start a guest like following

# virsh dumpxml r7.2-new | grep cpu -A 9
  <vcpu placement='static' current='1'>7</vcpu>

# virsh schedinfo r7.2-new
Scheduler      : posix
cpu_shares     : 1024
vcpu_period    : 100000
vcpu_quota     : -1
emulator_period: 100000
emulator_quota : -1

2.set schedinfo value for guest

# virsh schedinfo r7.2-new --set vcpu_quota=1111
Scheduler      : posix
cpu_shares     : 1024
vcpu_period    : 100000
vcpu_quota     : 1111
emulator_period: 100000
emulator_quota : -1

check in cgroup :

# cat /sys/fs/cgroup/cpu/machine.slice/machine-qemu\\x2dr7.2\\x2dnew.scope/vcpu0/cpu.cfs_quota_us
1111

3.Using setvcpus to change guest vcpu

# virsh setvcpus r7.2-new 4 --live

# virsh dumpxml r7.2-new | grep cpu -A 9
  <vcpu placement='static' current='4'>7</vcpu>
  <cputune>
    <quota>1111</quota>
  </cputune>

check in cgroup :
# cat /sys/fs/cgroup/cpu/machine.slice/machine-qemu\\x2dr7.2\\x2dnew.scope/vcpu0/cpu.cfs_quota_us
1111
# cat /sys/fs/cgroup/cpu/machine.slice/machine-qemu\\x2dr7.2\\x2dnew.scope/vcpu1/cpu.cfs_quota_us
-1
# cat /sys/fs/cgroup/cpu/machine.slice/machine-qemu\\x2dr7.2\\x2dnew.scope/vcpu2/cpu.cfs_quota_us
-1
# cat /sys/fs/cgroup/cpu/machine.slice/machine-qemu\\x2dr7.2\\x2dnew.scope/vcpu3/cpu.cfs_quota_us
-1



Actual results:
As step3 , the new vcpus in cgroup cannot get vcpu_quota I set before .

Expected results:
The new vcpus should inherit the cputune value I set before .

Additional info:
Comment 3 Peter Krempa 2016-02-08 11:10:25 EST
Fixed upstream:

commit c6bd15026bc14c7a3a6c9f6d8d9758fdefbf81fe
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Wed Jan 13 17:00:54 2016 +0100

    qemu: vcpu: Reuse qemuProcessSetupVcpu in vcpu hotplug
    
    Since majority of the steps is shared, the function can be reused to
    simplify code.
    
    Additionally this resolves
    https://bugzilla.redhat.com/show_bug.cgi?id=1244128 since the cpu
    bandwidth limiting with cgroups would not be set on the hotplug path.
    
    Additionally the code now sets the thread affinity and honors autoCpuset
    as in the regular startup code path.

commit 56971667ee4a5a5f68987be84b3c1461537451de
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Wed Jan 13 16:36:52 2016 +0100

    qemu: vcpu: Aggregate code to set vCPU tuning
    
    Rather than iterating 3 times for various settings this function
    aggregates all the code into single place. One of the other advantages
    is that it can then be reused for properly setting vCPU info on hotplug.
    
    With this approach autoCpuset is also used when setting the process
    affinity rather than just via cgroups.

v1.3.1-164-gc6bd150
Comment 5 Pei Zhang 2016-07-20 23:29:50 EDT
Verify version: 
libvirt-2.0.0-2.el7.x86_64

Verify steps : 

1. define a guest, set cputune 
# virsh schedinfo vm1 --set vcpu_quota=1000000000 --config 
Scheduler      : posix
cpu_shares     : 0
vcpu_period    : 0
vcpu_quota     : 1000000000
emulator_period: 0
emulator_quota : 0
global_period  : 0
global_quota   : 0

2. change vcpu numbers, start guest 
# virsh setvcpus vm1 4 --config

# virsh start vm1
Domain vm1 started


# virsh dumpxml vm1|grep cputune -A 5
  <cputune>
    <quota>1000000000</quota>
......

# virsh schedinfo vm1 
Scheduler      : posix
cpu_shares     : 1024
vcpu_period    : 100000
vcpu_quota     : 1000000000
emulator_period: 100000
emulator_quota : -1
global_period  : 100000
global_quota   : -1

3. check values in cgroup 
# cat /sys/fs/cgroup/cpu\,cpuacct/machine.slice/machine-qemu\\x2d15\\x2dvm1.scope/vcpu0/cpu.cfs_quota_us 
1000000000

as above, cat value in vcpu1, vcpu2, vcpu3

4. Using setvcpus to change the number of vcpu

# virsh setvcpus vm1 6 --live 

check in cgroup again :
# cat /sys/fs/cgroup/cpu\,cpuacct/machine.slice/machine-qemu\\x2d15\\x2dvm1.scope/vcpu4/cpu.cfs_quota_us 
1000000000

# cat /sys/fs/cgroup/cpu\,cpuacct/machine.slice/machine-qemu\\x2d15\\x2dvm1.scope/vcpu5/cpu.cfs_quota_us 
1000000000

Now the value can be set on hot plug path, move this bug to verified.
Comment 7 errata-xmlrpc 2016-11-03 14:19:53 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-2577.html

Note You need to log in before you can comment on or make changes to this bug.