You are here

Pin CPUs with the ovm_vmcontrol Utility

In this section, we will pin a virtual machine with two CPUs to various CPU threads using the ovm_vmcontrol utility. A virtual machine's CPUs can be immediately pinned to any CPU core or thread using the ovm_vmcontrol utility as well as with the xm command, xm vcpu-set. This section of the Oracle Cloud Cookbook reviews CPU pinning with the ovm_vmcontrol utility.
 
Note: The Max. Processors property shows the maximum number of CPUs that can be allocated and/or pinned. The number of processors is actually the number of allocated physical CPU cores or threads, and is limited to 128. The Max. Processors property can only be edited when a virtual machine is stopped. The Processors property shows the current number of allocated CPUs. The Processors property can be changed with running virtual machine up to the value of Max. Processors. 
 
Figure 8 shows the CPU properties for the example virtual machine used through this chapter. The ID and the CPU allocations are highlighted in red.
Oracle VM Virtaul Machine Properties
 
The virtual machine's ID is 0004fb0000060000dbf90ab3718822c0 with two CPUs allocated.
 
The Oracle VM 3 utilities' ovm_vmcontrol is an ideal tool used to query and immediately set virtual machine CPU pinning using Oracle VM Manager. The Oracle VM utilities provide a command line interface for Oracle VM Manager. The Oracle VM utilities allow Oracle VM Manager administrative tasks such as CPU pinning to be performed from the command line or executed using scripts.
 

Before you pin a virtual machine's CPUs to an Oracle VM Server's CPU cores, it is necessary to understand the Oracle VM Server's CPU topology. There are a number of commands to list an Oracle VM Server's CPU topology. The xenpm command is my favorite command, xenpm stands for Xen Power Management. Xenpm is a userspace program that lists CPU power information and provides control over power policies. Type xenpm or xenpm --help to print the xenpm command list.

 
The next exmple shows the CPU topology from the Oracle VM Server used through this section. The example Oracle VM Server has 1 CPU, 4 cores with hyperthreading enabled.
 
#  xenpm get-cpu-topology
CPU     core    socket  node
CPU0     0       0       0
CPU1     0       0       0
CPU2     1       0       0
CPU3     1       0       0
CPU4     2       0       0
CPU5     2       0       0
CPU6     3       0       0
CPU7     3       0       0
 
The next example shows how to query the CPU pinning from a virtual machine named yum-chekov. Substitute admin with your Oracle VM Manager user account, password with your admin user account password, and yum-chekov with the name of your virtual machine, i.e. the name displayed in Oracle VM Manager.
 
Run ovm_vmcontrol from the Oracle VM Manager host:
 
./ovm_vmcontrol -u admin -p password -h localhost -v yum-chekov -c vcpuget
Oracle VM VM Control utility 0.5.2.
Connected.
Command : vcpuget
Virtual Machine 'yum-sulu' has no pinned vcpus.
 
The above example shows that the virtual machine is not pinned.
 
The next example shows how to pin both CPUs to core 0. Run ovm_vmcontrol from the Oracle VM Manager host.

# ./ovm_vmcontrol -u admin -p password -h localhost -v yum-chekov -c vcpuset -s 0
Oracle VM VM Control utility 0.5.2.
Connected.
Command : vcpuset
Pinning virtual CPUs
Pinning of virtual CPUs to physical threads  '0' 'yum-chekov' completed.
 
To confirm CPU pinning, access the Oracle VM Server running the pinned virtual machine, (Oracle VM Manager shows which server virtual machines are running on and the virtual machine's UUID/name), and as root type "xm vcpu-list Domain ID or UUID". The next example shows the output from "xm vcpu-list Domain ID or UUID" for yum-chekov. Replace 0004fb0000060000dbf90ab3718822c0 with your virtual machines name or ID, i.e. type xm list to list the running virtual machines on a host.

# xm vcpu-list 0004fb0000060000dbf90ab3718822c0
Name                                ID  VCPU   CPU State   Time(s) CPU Affinity
0004fb0000060000dbf90ab3718822c0    41     0     0   -b-      17.0 0
0004fb0000060000dbf90ab3718822c0    41     1     0   -b-      40.4 0

The next example shows how to pin both CPUs to core 0 and 3. Run ovm_vmcontrol from the Oracle VM Manager host.

# ./ovm_vmcontrol -u admin -p password -h localhost -v yum-chekov -c vcpuset -s 0,3
Oracle VM VM Control utility 0.5.2.
Connected.
Command : vcpuset
Pinning virtual CPUs
Pinning of virtual CPUs to physical threads  '0,3' 'yum-chekov' completed.
 
To confirm CPU pinning, access the Oracle VM Server running the pinned virtual machine, (Oracle VM Manager shows which server virtual machines are running on and the virtual machine's UUID/name), and as root type "xm vcpu-list Domain ID or UUID". The next example shows the output from "xm vcpu-list Domain ID or UUID" for yum-chekov. Replace 0004fb0000060000dbf90ab3718822c0 with your virtual machines name or ID, i.e. type xm list to list the running virtual machines on a host.

# xm vcpu-list 0004fb0000060000dbf90ab3718822c0
Name                                ID  VCPU   CPU State   Time(s) CPU Affinity
0004fb0000060000dbf90ab3718822c0    41     0     0   -b-      17.3 0,3
0004fb0000060000dbf90ab3718822c0    41     1     3   -b-      40.5 0,3

The next example shows how to pin both CPUs to core 1 and 2. Run ovm_vmcontrol from the Oracle VM Manager host.

# ./ovm_vmcontrol -u admin -p password -h localhost -v yum-chekov -c vcpuset -s 1,2
Oracle VM VM Control utility 0.5.2.
Connected.
Command : vcpuset
Pinning virtual CPUs
Pinning of virtual CPUs to physical threads  '1,2' 'yum-chekov' completed.

To confirm CPU pinning, access the Oracle VM Server running the pinned virtual machine, (Oracle VM Manager shows which server virtual machines are running on and the virtual machine's UUID/name), and as root type "xm vcpu-list Domain ID or UUID". The next example shows the output from "xm vcpu-list Domain ID or UUID" for yum-chekov. Replace 0004fb0000060000dbf90ab3718822c0 with your virtual machines name or ID, i.e. type xm list to list the running virtual machines on a host.

# xm vcpu-list 0004fb0000060000dbf90ab3718822c0
Name                                ID  VCPU   CPU State   Time(s) CPU Affinity
0004fb0000060000dbf90ab3718822c0    41     0     2   -b-      17.4 1-2
0004fb0000060000dbf90ab3718822c0    41     1     1   -b-      40.7 1-2
 

Download PDF Now!