Bug 1131486

Summary: libvirt should ignore 'cpuset' specified by vcpu if attribute 'emulatorpin' or 'vcpupin' is specified
Product: Red Hat Enterprise Linux 7 Reporter: yanbing du <ydu>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: dyuan, honzhang, lhuang, mkletzan, mzhan, pkrempa, rbalakri
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.2.16-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 05:47:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description yanbing du 2014-08-19 11:57:23 UTC
Description of problem:
"""
If attribute emulatorpin of cputune is specified, cpuset specified by vcpu here will be ignored; Similarly, For virtual CPUs which has vcpupin specified, cpuset specified by cpuset here will be ignored; For virtual CPUs which doesn't have vcpupin specified, it will be pinned to the physical CPUs specified by cpuset here
"""

Version-Release number of selected component (if applicable):
libvirt-1.2.7-1.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Set 'cpuset' in <vcpu> element:
# virsh dumpxml test|grep cpu
  <vcpu placement='static' cpuset='1'>1</vcpu>
# virsh start test
2. Do vcpupin or emulatorpin
# virsh vcpupin test 0 0
error: Requested operation is not valid: failed to set cpuset.cpus in cgroup for vcpu 0

# virsh emulatorpin test 0
error: Requested operation is not valid: failed to set cpuset.cpus in cgroup for emulator threads

or set 'cpuset' in <vcpu> element and set 'cpuset' in <cputune> element, then try to start domain
# virsh dumpxml test|grep cpu
  <vcpu placement='static' cpuset='1'>1</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='0'/>
  </cputune>
# virsh start test
error: Failed to start domain test
error: Unable to write to '/sys/fs/cgroup/cpuset/machine.slice/machine-qemu\x2dtest.scope/vcpu0/cpuset.cpus': Permission denied


Actual results:


Expected results:
'cpuset' specified by vcpu should be ignored if attribute 'emulatorpin' or 'vcpupin' is specified

Additional info:
Come from bug https://bugzilla.redhat.com/show_bug.cgi?id=838070#c17

Comment 3 Peter Krempa 2015-05-15 09:02:49 UTC
Fixed upstream:

commit f0fa9080d47b7aedad6f4884b8879d88688752a6
Author: Peter Krempa <pkrempa>
Date:   Fri Mar 27 10:23:19 2015 +0100

    qemu: cgroup: Properly set up vcpu pinning
    
    When the default cpuset or automatic numa placement is used libvirt
    would place the whole parent cgroup in the specified cpuset. This then
    disallowed to re-pin the vcpus to a different cpu.
    
    This patch pins only the vcpu threads to the default cpuset and thus
    allows to re-pin them later.
    
    The following config would fail to start:
    <domain type='kvm'>
      ...
      <vcpu placement='static' cpuset='0-1' current='2'>4</vcpu>
      <cputune>
        <vcpupin vcpu='0' cpuset='2-3'/>
        ...
    
    This is a regression since a39f69d2b.

v1.2.14-4-gf0fa908

Comment 5 Luyao Huang 2015-07-22 09:26:46 UTC
Verify this bug with libvirt-1.2.17-2.el7.x86_64:

1. prepare a guest with cpuset and vcpupin, iothreadpin, emulatorpin:

# virsh dumpxml test4

  <vcpu placement='static' cpuset='2' current='2'>4</vcpu>
  <iothreads>3</iothreads>
  <cputune>
    <vcpupin vcpu='0' cpuset='1'/>
    <emulatorpin cpuset='3'/>
    <iothreadpin iothread='1' cpuset='0'/>
  </cputune>


2. start it:

# virsh start test4
Domain test4 started

3. check cgroup

# cgget -g cpuset /machine.slice/machine-qemu\\x2dtest4.scope/emulator
/machine.slice/machine-qemu\x2dtest4.scope/emulator:
cpuset.memory_spread_slab: 0
cpuset.memory_spread_page: 0
cpuset.memory_pressure: 0
cpuset.memory_migrate: 1
cpuset.sched_relax_domain_level: -1
cpuset.sched_load_balance: 1
cpuset.mem_hardwall: 0
cpuset.mem_exclusive: 0
cpuset.cpu_exclusive: 0
cpuset.mems: 0
cpuset.cpus: 3

# cgget -g cpuset /machine.slice/machine-qemu\\x2dtest4.scope/iothread1
/machine.slice/machine-qemu\x2dtest4.scope/iothread1:
cpuset.memory_spread_slab: 0
cpuset.memory_spread_page: 0
cpuset.memory_pressure: 0
cpuset.memory_migrate: 1
cpuset.sched_relax_domain_level: -1
cpuset.sched_load_balance: 1
cpuset.mem_hardwall: 0
cpuset.mem_exclusive: 0
cpuset.cpu_exclusive: 0
cpuset.mems: 0
cpuset.cpus: 0

# cgget -g cpuset /machine.slice/machine-qemu\\x2dtest4.scope/vcpu0
/machine.slice/machine-qemu\x2dtest4.scope/vcpu0:
cpuset.memory_spread_slab: 0
cpuset.memory_spread_page: 0
cpuset.memory_pressure: 0
cpuset.memory_migrate: 1
cpuset.sched_relax_domain_level: -1
cpuset.sched_load_balance: 1
cpuset.mem_hardwall: 0
cpuset.mem_exclusive: 0
cpuset.cpu_exclusive: 0
cpuset.mems: 0
cpuset.cpus: 1

4. check other 

# cgget -g cpuset /machine.slice/machine-qemu\\x2dtest4.scope/vcpu1
/machine.slice/machine-qemu\x2dtest4.scope/vcpu1:
cpuset.memory_spread_slab: 0
cpuset.memory_spread_page: 0
cpuset.memory_pressure: 0
cpuset.memory_migrate: 1
cpuset.sched_relax_domain_level: -1
cpuset.sched_load_balance: 1
cpuset.mem_hardwall: 0
cpuset.mem_exclusive: 0
cpuset.cpu_exclusive: 0
cpuset.mems: 0
cpuset.cpus: 2

# cgget -g cpuset /machine.slice/machine-qemu\\x2dtest4.scope/iothread2
/machine.slice/machine-qemu\x2dtest4.scope/iothread2:
cpuset.memory_spread_slab: 0
cpuset.memory_spread_page: 0
cpuset.memory_pressure: 0
cpuset.memory_migrate: 1
cpuset.sched_relax_domain_level: -1
cpuset.sched_load_balance: 1
cpuset.mem_hardwall: 0
cpuset.mem_exclusive: 0
cpuset.cpu_exclusive: 0
cpuset.mems: 0
cpuset.cpus: 2

# cgget -g cpuset /machine.slice/machine-qemu\\x2dtest4.scope/iothread3
/machine.slice/machine-qemu\x2dtest4.scope/iothread3:
cpuset.memory_spread_slab: 0
cpuset.memory_spread_page: 0
cpuset.memory_pressure: 0
cpuset.memory_migrate: 1
cpuset.sched_relax_domain_level: -1
cpuset.sched_load_balance: 1
cpuset.mem_hardwall: 0
cpuset.mem_exclusive: 0
cpuset.cpu_exclusive: 0
cpuset.mems: 0
cpuset.cpus: 2

Comment 7 errata-xmlrpc 2015-11-19 05:47:39 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/RHBA-2015-2202.html