This note describes the options that exist with Oracle VM to bind guest or virtual machineCPUs to physical CPUs or cores.
IMPORTANT : for Oracle licensing policies and support around hard-partitioning please go to the licensing website.
OracleVM hard partitioningthe hypervisor has the following commands to be used for binding CPUs :
xm vcpu-set <domain> <count> configures number of virtual CPUs a guest or virtual machine <domain> sees
xm vcpu-list <domain> lists the virtual cpu information of a given guest or virtual machine (or all if you omit <domain>
xm vcpu-pin <domain> <virtual cpu> <real cpus> pins virtual cpus to run only on specific cpus. defaults to all . pinning cpus means that xen enforces and controls which physical processor can/will be used to schedule/rn virtual cpus on (no matter how many virtual cpus you choose)
alternatively, this can be hardcoded in the vm.cfg file for each guest or virtual machine :
vm.cfg examples :
cpus = '0-3' or
cpus = '0,1' in the first case, only CPUs (or cores in actuality) 0 1 2 3 can be used for the guest
in the second case, cores 0 and 1
if I have a guest that has 4 virtual CPUs and put cpus = '0' in the vm.cfg file, then all 4 vCPUs will be scheduled on the same physical core
if I have a guest that has 4 virtual CPUs andwant them to run on 2 cores, the I could have cpus = '0,1' in my config
examples on an 8 core system :
[root@ca-ostest256 ~]# xm vcpu-list guest1
Name ID VCPU CPU State Time(s)
CPU Affinity guest1 4 0 4 -b- 8645.7
any cpu guest1 4 1 4 -b- 9843.6
any cpu 2 virtual CPUs and they can run on any of the 8 cores.
[root@ca-ostest256 ~]# xm vcpu-list guest1
Name ID VCPU CPU State Time(s)
CPU Affinity guest1 26 0 0 -b- 8646.6
0 guest1 26 1 0 -b- 9844.3
0 2 virtual CPUs and they can run only on physical core 0
[root@ca-ostest256 ~]# xm vcpu-list guest1
Name ID VCPU CPU State Time(s)
CPU Affinity guest1 26 0 0 -b- 8647.8
0 guest1 26 1 1 -b- 9845.0
1 2 virtual CPUs and they can run on 2 physical cores 0, 1
if I put cpus='0' on my guest config and I have 2 virtual CPUs then at startup of the guest :
Name ID VCPU CPU State Time(s)
CPU Affinity guest1 45 0 0 r-- 4.3
0 guest1 45 1 - --p 0.0
0 NOTE :
on live migration, when using xm vcpu-pin or when you modify the config file using cpus = '', the settings are lost and you need to repin the cpus on the other physical machine.