Hi~
Users can use vcpupin command to bind a vcpu thread to a specific physical cpu.
But besides vcpu threads, there are alse some other threads created by qemu
(known as hypervisor threads) that could not be explicitly bound to physical cpus.
The first 3 patches are from Wen Congyang, which implement Cgroup for differrent
hypervisors.
The other 10 patches implemented hypervisor threads binding, in two ways:
1) Use sched_setaffinity() function;
2) In cpuset cgroup.
A new xml element is introduced, and vcpupin command is improved, see below.
1. Introduce new xml elements:
<cputune>
......
<hypervisorpin cpuset='1'/>
</cputune>
2. Improve vcpupin command to support hypervisor threads binding.
For example, vm1 has the following configuration:
<cputune>
<vcpupin vcpu='1' cpuset='1'/>
<vcpupin vcpu='0' cpuset='0'/>
<hypervisorpin cpuset='1'/>
</cputune>
1) query all threads pining
# vcpupin vm1
VCPU: CPU Affinity
----------------------------------
0: 0
1: 1
Hypervisor: CPU Affinity
----------------------------------
*: 1
2) query hypervisor threads pining only
# vcpupin vm1 --hypervisor
Hypervisor: CPU Affinity
----------------------------------
*: 1
3) change hypervisor threads pining
# vcpupin vm1 --hypervisor 0-1
# vcpupin vm1 --hypervisor
Hypervisor: CPU Affinity
----------------------------------
*: 0-1
# taskset -p 397
pid 397's current affinity mask: 3
Note: If users want to pin a vcpu thread to pcpu, --vcpu option could no longer be
omitted.
Tang Chen (10):
Enable cpuset cgroup and synchronous vcpupin info to cgroup.
Support hypervisorpin xml parse.
Introduce qemuSetupCgroupHypervisorPin and synchronize hypervisorpin
info to cgroup.
Add qemuProcessSetHypervisorAffinites and set hypervisor threads
affinities
Introduce virDomainHypervisorPinAdd and virDomainHypervisorPinDel
functions
Introduce qemudDomainPinHypervisorFlags and
qemudDomainGetHypervisorPinInfo in qemu driver.
Introduce remoteDomainPinHypervisorFlags and
remoteDomainGetHypervisorPinInfo functions in remote driver.
Introduce remoteDispatchDomainPinHypervisorFlags and
remoteDispatchDomainGetHypervisorPinInfo functions.
Introduce virDomainPinHypervisorFlags and
virDomainGetHypervisorPinInfo functions.
Improve vcpupin to support hypervisorpin dynically.
Wen Congyang (3):
Introduce the function virCgroupForHypervisor
introduce the function virCgroupMoveTask()
create a new cgroup and move all hypervisor threads to the new cgroup
daemon/remote.c | 103 +++++++++
docs/schemas/domaincommon.rng | 7 +
include/libvirt/libvirt.h.in | 9 +
src/conf/domain_conf.c | 173 +++++++++++++++-
src/conf/domain_conf.h | 7 +
src/driver.h | 13 +-
src/libvirt.c | 147 +++++++++++++
src/libvirt_private.syms | 6 +
src/libvirt_public.syms | 6 +
src/qemu/qemu_cgroup.c | 149 +++++++++++++-
src/qemu/qemu_cgroup.h | 5 +
src/qemu/qemu_driver.c | 266 ++++++++++++++++++++++-
src/qemu/qemu_process.c | 58 +++++
src/remote/remote_driver.c | 102 +++++++++
src/remote/remote_protocol.x | 24 ++-
src/remote_protocol-structs | 24 ++
src/util/cgroup.c | 132 +++++++++++-
src/util/cgroup.h | 9 +
tests/qemuxml2argvdata/qemuxml2argv-cputune.xml | 1 +
tests/vcpupin | 6 +-
tools/virsh.c | 145 ++++++++----
tools/virsh.pod | 16 +-
22 files changed, 1335 insertions(+), 73 deletions(-)
--
1.7.3.1