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.

Before binding NIC interrupts to CPU cores, disable irqbalance.

Procedure

  1. Stop the irqbalance service.
    1
    systemctl stop irqbalance.service
    
  2. Disable the irqbalance service.
    1
    systemctl disable irqbalance.service
    
  3. Check whether the irqbalance service is disabled.
    1
    systemctl status irqbalance.service
    

    If the status is inactive, the irqbalance service is disabled.

  4. Bind NIC interrupts to CPU cores.

    The optimal number of CPUs for binding interrupts varies depending on the hardware configuration. For example, if the 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 script is the optimal interrupt binding setting for the combination of the Kunpeng 920 5250 processor and Huawei TM280 25G NIC.

     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
    
    In the script, the first parameter $1 is the NIC name, the second parameter $2 is the number of queues (32), and the third parameter $3 is the name of the bus corresponding to the NIC.
    • Query the NIC name:
      ip a
    • Query the number of queues:
      ethtool -l NIC name
    • Query the bus name:
      ethtool -i NIC name