Rate This Document
Findability
Accuracy
Completeness
Readability

Binding NIC Interrupts to Cores

Purpose

Manually bind network interface card (NIC) interrupts to CPU cores based on the mapping between NICs and CPUs to optimize the system network performance.

Procedure

The optimal number of CPUs for binding interrupts varies depending on the hardware configuration. For example, if the Huawei Kunpeng 920 5250 processor and Huawei TM280 25G NIC (LOM on a Kunpeng server) are used, a maximum of 32 interrupt queues can be bound. It is recommended that all queues be used for interrupt binding to achieve optimal performance.

The following lists the setting of the script. The first parameter $1 specifies the NIC name. The second parameter $2 specifies the number of queues, which is 32 in this example. The third parameter $3 specifies the bus name corresponding to the NIC. You can run the ethtool -i <NIC name> command to query the bus name.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#!/bin/bash
eth1=$1
cnt=$2
bus=$3
ethtool -L $eth1 combined $cnt

irq1=`cat /proc/interrupts| grep -E ${bus} | head -n$cnt | awk -F ':' '{print $1}'`
irq1=`echo $irq1`
cpulist=(0 1 2 3 4 5 6 7 {51..71} 93 94 95)
c=0
for irq in $irq1
do
    echo ${cpulist[c]} "->" $irq
    echo ${cpulist[c]} > /proc/irq/$irq/smp_affinity_list
    let "c++"
done