If an NIC receives a large number of requests, the NIC triggers the interrupt program to notify the kernel of new data packets. Then, the kernel invokes the interrupt handler to copy the data packets from the NIC to the memory. If an NIC has only one queue, the copies of data packets received simultaneously can be processed only by one CPU core. To address this problem, the multi-queue NIC mechanism is introduced. With multi-queue NIC enabled, CPU cores can obtain data packets from different NIC queues at the same time.
When the multi-queue NIC function is enabled, the OS uses the Irqbalance service to determine which CPU core processes which data packets. However, if the CPU core that processes the interrupt and the NIC are not on the same NUMA node, cross-NUMA memory access is triggered. Therefore, set the CPU core that processes the NIC interrupt on the same NUMA node as the NIC to reduce additional overheads caused by cross-NUMA memory access, and improve network processing performance.
You are advised to bind cores for NIC interrupts.
Procedure (CentOS is used as an example):
1) Check whether the NIC supports multi-queue (supported by independent NICs). ethX indicates the network port name. In the command output, the value of Combined under Pre-set maximums indicates the maximum number of queues supported.
# ethtool –l ethX
2) Stop irqbalance.
# systemctl stop irqbalance.service
# systemctl disable irqbalance.service
3) Query the NUMA node corresponding to the NIC.
# cat /sys/class/net/ethX/device/numa_node
4) Set the number of NIC queues to the number of CPU cores on the NUMA node. (Adjust the value based on the maximum number of NIC queues supported.)
# ethtool -L ethx combined 24
5) Query the interrupt ID $irq.
# cat /proc/interrupts | grep $eth | awk -F ':' '{print $1}'
6) Bind each interrupt to a core of the NUMA node corresponding to the NIC based on the interrupt ID. $cpuMask indicates the core ID. You can run the numactl -H | grep cpus command to query the core IDs of the NUMA node.
# echo $cpuMask > /proc/irq/$irq/smp_affinity_list
