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.
- Open the /etc/grub2-efi.cfg file.
vi /etc/grub2-efi.cfg
- 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.
- Press Esc, type :wq!, and press Enter to save the file and exit.
- 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.
- Set the number of NIC queues to 1.
- Check the network port name.
ip a
- Set the number of NIC queues. Replace Network_port_name with an actual one.
ethtool -L Network_port_name combined 1
- Check the network port name.
- Bind NIC interrupts to cores.
- 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.
- 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.
- Stop and disable the irqbalance service.
systemctl stop irqbalance systemctl disable irqbalance
- Run the script.
- Create a Bash script file named irq.sh. Write the following content to the file to bind NIC interrupts to specific CPU cores:
Parent topic: Redis Performance Tuning