Binding NIC Interrupts to Cores
Purpose
Compared with using irqbalance of the kernel to schedule NIC interrupts on all cores, using manual core binding to fix interrupts can effectively improve the capability of the service network to receive and send packets.
Procedure
- Disable irqbalance.
Before binding cores to NICs, disable irqbalance.
- Stop the irqbalance service. The setting will be invalid after the system restarts.
1systemctl stop irqbalance.service
- Disable the irqbalance service. This setting is permanently valid.
1systemctl disable irqbalance.service
- Check whether the irqbalance service is disabled.
- Stop the irqbalance service. The setting will be invalid after the system restarts.
- Check the PCI device number of the NIC, assuming that the current NIC name is enp131s0.
1ethtool -i enp131s0

- Check the NUMA node to which the PCIe NIC connects.
1lspci -vvvs <bus-info>

- Check the core range corresponding to a NUMA node. For example, the core range can be 48 to 63.
1lscpu

- Bind interrupts to cores. The Hi1822 NIC has 16 queues. Bind the interrupts to the 16 cores of the NUMA node to which the NIC connect (for example, cores 48 to 63 corresponding to NUMA node 1).
- Create a script.
1vi smartIrq.sh - Press i to enter the insert mode and add the following content to the file:
1 2 3 4 5 6 7 8 9
#!/bin/bash irq_list=(`cat /proc/interrupts | grep enp131s0 | awk -F: '{print $1}'`) cpunum=48 # Change the value to the first core of the node. for irq in ${irq_list[@]} do echo $cpunum > /proc/irq/$irq/smp_affinity_list echo `cat /proc/irq/$irq/smp_affinity_list` (( cpunum+=1 )) done
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Bind interrupts to cores.
1bash smartIrq.sh
- Create a script.
- Run the following command to check whether the core binding is successful.
- Create a script.
1vi irqCheck.sh - Press i to enter the insert mode and add the following content to the file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/bin/bash # NIC name intf=$1 log=irqSet-`date "+%Y%m%d-%H%M%S"`.log # Number of available CPUs cpuNum=$(cat /proc/cpuinfo |grep processor -c) # RX and TX interrupt lists irqListRx=$(cat /proc/interrupts | grep ${intf} | awk -F':' '{print $1}') irqListTx=$(cat /proc/interrupts | grep ${intf} | awk -F':' '{print $1}') # Bind the RX interrupt requests (IRQs). for irqRX in ${irqListRx[@]} do cat /proc/irq/${irqRX}/smp_affinity_list done # Bind the TX IRQs. for irqTX in ${irqListTx[@]} do cat /proc/irq/${irqTX}/smp_affinity_list done
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Check whether the core binding is successful.
- Create a script.
Parent topic: Hardware Tuning