Rate This Document
Findability
Accuracy
Completeness
Readability

Tuning the OS

Tune the OSs of the physical machine and VM to improve server performance.

Physical Machine

Modify the GRUB parameters to tune the OS of the physical machine.

  1. Open the /etc/grub2-efi.cfg file.
    vi /etc/grub2-efi.cfg
  2. Press i to enter the insert mode and add the following IOMMU configurations to the end of the kernel parameters:
    iommu.passthrough=1 pci=realloc kvm-arm.vgic_v4_enable=1

    kvm-arm.vgic_v4_enable=1 is applicable only to new Kunpeng 920 processor models.

  3. Press Esc, type :wq!, and press Enter to save the file and exit.
  4. Restart the physical machine OS for the configuration to take effect.

Virtual Machine

Set the number of NIC queues and optimize NIC interrupt-core binding to tune the VM OS.

  1. Set the number of NIC queues to 1.
    1. Check the network port name.
      ip a
    2. Set the number of NIC queues. Replace Network_port_name with an actual one.
      ethtool -L Network_port_name combined 1
  2. Bind NIC interrupts to cores.
    1. Create a Bash script file named irq.sh. Write the following content to the file to bind NIC interrupts to specific CPU cores:
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      #!/bin/bash
      
      iface=$1
      start_core=$2
      end_core=$3
      
      irq_list=(`cat /proc/interrupts |grep ${iface} | awk -F: '{print $1}'`)
      
      ncpu=$start_core
      
      for irq in ${irq_list[@]}
      do
              echo ${ncpu} > /proc/irq/${irq}/smp_affinity_list
              echo `cat /proc/irq/${irq}/smp_affinity_list`
              (( ncpu+=1 ))
              if (( ${ncpu} > $end_core )); then
                      ncpu=$start_core
              fi
      done
      

      The input parameters for binding interrupts to cores are described as follows:

      • iface: NIC interrupt name, for example, virtio*-input.0. Asterisk (*) indicates the sequence number of the actual network port queue name. Change it based on actual requirements.

        Run the following command to check the network port queue name:

        cat /proc/interrupts
      • start_core: ID of the CPU core that starts the binding, for example, 0. Change it as required.
      • end_core: ID of the CPU core that ends the binding, for example, 1 (if there is only one core). Change it as required.
    2. Stop and disable the irqbalance service.
      systemctl stop irqbalance
      systemctl disable irqbalance
    3. Run the script.
      Bind virtio*-input.0 and virtio*-output.0 to the same CPU core for isolation from services. For example, bind them to the CPU core whose ID is 1.
      bash irq.sh virtio*-input.0 1 1
      bash irq.sh virtio*-output.0 1 1