Sunday, January 15, 2017

Distributing interrupts of network controller to all cpus

Advertisements

When we use PCI network card, for eg 10g fiber NIC, it will have more than one channels. Our Server will have many CPUs also. If all the channels of the NIC is interrupting only one CPU, there will be huge stress on the single CPU and it will decrease the performance of network, server etc.

The best way to handle this distribute the interrupts to all the cpus available in the system. In this post we will see how to do it.

I have one PCI Fiber NIC, eth2.

[root@main scripts]# ifconfig
eth2      Link encap:Ethernet  HWaddr 14:02:EC:6C:5A:XX
          inet addr:172.16.0.30  Bcast:172.16.0.127  Mask:255.255.255.128
          inet6 addr: fe80::1602:ecff:fe6c:5a68/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:23985923006 errors:13425 dropped:0 overruns:0 frame:13425
          TX packets:18582827575 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:21135762796818 (19.2 TiB)  TX bytes:23298305448313 (21.1 TiB)

Initially, we can see that all the channels are interrupting singe cpu CPU0
[root@main ~]# cat /proc/interrupts
           CPU0       CPU1       CPU2       CPU3       CPU4       CPU5
 75: 1937793764          0          0          0          0          0  IR-PCI-MSI-edge      eth2-TxRx-0
 76: 1033638701          0          0          0          0          0  IR-PCI-MSI-edge      eth2-TxRx-1
 77:  242534932           0          0          0          0          0  IR-PCI-MSI-edge      eth2-TxRx-2
 78:  100181128           0          0          0          0          0  IR-PCI-MSI-edge      eth2-TxRx-3
 79:   64797499            0          0          0          0          0  IR-PCI-MSI-edge      eth2-TxRx-4
 80:   50919167            0          0          0          0          0  IR-PCI-MSI-edge      eth2-TxRx-5
 81:      15920               0          0          0          0          0  IR-PCI-MSI-edge      eth2

Now we are running the set irq affinity script with eth2 as argument. You can get this script from intel websites. 
[root@main scripts]# ./set_irq_affinity eth2
IFACE CORE MASK -> FILE
=======================
eth2 0 1 -> /proc/irq/75/smp_affinity
eth2 1 2 -> /proc/irq/76/smp_affinity
eth2 2 4 -> /proc/irq/77/smp_affinity
eth2 3 8 -> /proc/irq/78/smp_affinity
eth2 4 10 -> /proc/irq/79/smp_affinity
eth2 5 20 -> /proc/irq/80/smp_affinity

Now we can see that the new interrupts are distributed over the cpus.
[root@main scripts]# cat /proc/interrupts | grep eth2
           CPU0       CPU1       CPU2       CPU3       CPU4       CPU5
 75: 1938401156          0          0          0          0          0   IR-PCI-MSI-edge      eth2-TxRx-0
 76: 1033645576        416        0          0          0          0   IR-PCI-MSI-edge      eth2-TxRx-1
 77:   242536923          0         45         0          0          0   IR-PCI-MSI-edge      eth2-TxRx-2
 78:   100182754          0          0         36         0          0   IR-PCI-MSI-edge      eth2-TxRx-3
 79:     64799086          0          0          0         38         0   IR-PCI-MSI-edge      eth2-TxRx-4
 80:     50920844          0          0          0          0         41  IR-PCI-MSI-edge      eth2-TxRx-5
 81:           15920          0          0          0          0          0   IR-PCI-MSI-edge      eth2
[root@main scripts]# cat /proc/interrupts | grep eth2
           CPU0       CPU1       CPU2       CPU3       CPU4       CPU5
 75: 1938413752          0          0          0          0          0    IR-PCI-MSI-edge      eth2-TxRx-0
 76: 1033645576        597        0          0          0          0    IR-PCI-MSI-edge      eth2-TxRx-1
 77:  242536923          0       1358        0          0          0    IR-PCI-MSI-edge      eth2-TxRx-2
 78:  100182754          0          0         78          0          0    IR-PCI-MSI-edge      eth2-TxRx-3
 79:    64799086          0          0           0         70         0    IR-PCI-MSI-edge      eth2-TxRx-4
 80:    50920844          0          0           0          0        115  IR-PCI-MSI-edge      eth2-TxRx-5
 81:          15920          0          0           0          0          0    IR-PCI-MSI-edge      eth2

No comments:

Post a Comment

Be nice. That's all.