Rate This Document
Findability
Accuracy
Completeness
Readability

Binding the VM to Cores

Binding the QEMU Process to Physical CPUs

The services of multiple VMs running on the same server are different, which causes different levels of resource occupation. For storage I/O-intensive VMs, storage I/O processes of different VMs need to be completely isolated to avoid interference of adjacent VMs. The QEMU process is the main service process for processing front-end and back-end services. Therefore, this process needs to be isolated.

When binding a VM to cores, it is recommended that physical CPUs 0 to 3 be reserved and not used.

  1. Open the XML configuration file of the VM.
    1
    virsh edit vm1
    

    vm1 is the VM name.

  2. Press i to enter the insert mode and modify the XML configuration as follows:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    <domain type = 'KVM'>
    ...
      <vcpu placement = 'static' cpuset='4-7'>4</vcpu>
      <cputune>
        <vcpupin vcpu='0' cpuset='4'/>
        <vcpupin vcpu='1' cpuset='5'/>
        <vcpupin vcpu='2' cpuset='6'/>
        <vcpupin vcpu='3' cpuset='7'/>
        <emulatorpin cpuset='4-7'/>
      </cputune>
    ...
    <domain>
    
    • emulatorpin cpuset='4-7': binds the QEMU main thread to physical CPUs 4 to 7.
    • vcpu placement = 'static' cpuset='4-7': enables the I/O thread and worker threads to use only cores 4 to 7. If this parameter is not configured, the VM task threads run on any core of the CPUs, resulting in more cross-NUMA and cross-DIE loss.
    • vcpupin binds each CPU thread to a core. If vcpupin is not used to bind CPU threads, the threads may switch between cores 4 to 7, causing extra overheads.
  3. Press Esc, type :wq!, and press Enter to save the file and exit.

Cross-CPU Cluster Core Binding

Kunpeng 920 series processors provides two super CPU clusters (SCCLs). Each SCCL contains six to eight CPU clusters, and each CPU cluster contains four cores. When binding CPUs to a KVM, you are advised to use CPUs across multiple CPU clusters to improve the KVM performance. This method can reduce bandwidth bottlenecks between the L3 cache and memory caused by core competition in the same CPU cluster.

  1. Query the NUMA node information and topology in the Linux system.
    1
    numactl -H
    

  2. Edit the VM XML configuration file in the Linux system and bind vCPUs to cores in as many CPU clusters as possible. The following is an example:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    <domain type = 'KVM'>
    ...
      <vcpu placement = 'static' cpuset='4,5,8,9,12,16,22,23'>8</vcpu>
      <cputune>
        <vcpupin vcpu='0' cpuset='4'/>
        <vcpupin vcpu='1' cpuset='5'/>
        <vcpupin vcpu='2' cpuset='8'/>
        <vcpupin vcpu='3' cpuset='9'/>
        <vcpupin vcpu='4' cpuset='12'/>
        <vcpupin vcpu='5' cpuset='16'/>
        <vcpupin vcpu='6' cpuset='22'/>
        <vcpupin vcpu='7' cpuset='23'/>
        </cputune>
    ...
    </domain>