[Qemu-devel] [PATCH 0/3] pin vcpus to pcpus(set CPU affinity).

Benyu Xu posted 3 patches 6 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1498921030-23255-1-git-send-email-benyux.xu@intel.com
Test FreeBSD failed
Test checkpatch passed
Test docker failed
Test s390x passed
cpus.c                | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++
include/qom/cpu.h     |   9 ++++
include/sysemu/cpus.h |   2 +
qemu-options.hx       |  19 ++++++++
vl.c                  | 115 +++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 271 insertions(+)
[Qemu-devel] [PATCH 0/3] pin vcpus to pcpus(set CPU affinity).
Posted by Benyu Xu 6 years, 9 months ago
Pin vcpus to pcpus(set CPU affinity).
When run a Qemu in terminal, if we want to set the cpu affinity, for example,
using the tool taskset, we should find the cpus' thread ID first and then 
pin it manually. It's a tedious process, now a new feature "vcpupin" can help
this. This feature will be helpful to do performance tuning, it's more 
flexible and easily to use than external tools.

Add option "-vcpupin [pcpu_id_list]" to implement this feature. use the host's
physical or logical processor(pcpu) id to made a list to set cpu affinity, the
vcpus will sequentially pin to the pcpus of this list.
This means we should use the option -smp to allocate vcpus.
Here use ',' to seperate the single id or id sequence,
     use '-' as the id sequence's connector. eg:
a)
    qemu ... -smp 8 -vcpupin 0,2,4,6-10 ...
    It means qemu will pin 8 vcpus one by one and 1:1 to pcpu 0,2,4,6,7,8,9,10.
b)
    qemu ... -smp 8 -vcpupin 6-10,0,4,2 ...
    It means qemu will pin 8 vcpus one by one and 1:1 to pcpu 6,7,8,9,10,0,4,2.
c)
    qemu ... -smp 8 -vcpupin auto ...
    It means qemu will pin 8 vcpus one by one and 1:1 to pcpu 0,1,2,3,4,5,6,7.



Benyu Xu (3):
  add some vcpu-pin related functions.
  vcpu pin:  parameters parse and execution.
  add option -vcpupin into qemu-options.

 cpus.c                | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/qom/cpu.h     |   9 ++++
 include/sysemu/cpus.h |   2 +
 qemu-options.hx       |  19 ++++++++
 vl.c                  | 115 +++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 271 insertions(+)

-- 
1.8.3.1