RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1244128 - Setvcpu should inherit the cputune value in cgroups was set before via schedinfo
Summary: Setvcpu should inherit the cputune value in cgroups was set before via schedinfo
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.2
Hardware: x86_64
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-07-17 08:53 UTC by Pei Zhang
Modified: 2016-11-03 18:19 UTC (History)
6 users (show)

Fixed In Version: libvirt-1.3.2-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-03 18:19:53 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2577 0 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2016-11-03 12:07:06 UTC

Description Pei Zhang 2015-07-17 08:53:38 UTC
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 16:10:25 UTC
Fixed upstream:

commit c6bd15026bc14c7a3a6c9f6d8d9758fdefbf81fe
Author: Peter Krempa <pkrempa>
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>
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-21 03:29:50 UTC
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 18:19:53 UTC
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.