title: linux network interface irq smp_affinity
body: <p>I am doing network performance tests, and realized the interface's interrupts processing on 8 cpus is not balanced. So I want to make them more balanced.</p>
  
  <p>I just set the files :</p>
  
  <pre><code>echo 11 &gt; /proc/irq/16/smp_affinity
  echo 22 &gt; /proc/irq/17/smp_affinity
  echo 44 &gt; /proc/irq/18/smp_affinity
  echo 88 &gt; /proc/irq/19/smp_affinity
  </code></pre>
  
  <p>where the 16 17 18 and 19 are my four IRQ no of my network interfaces.</p>
  
  <pre><code>[root@localhost ~]# cat /proc/interrupts | grep ens
    16:      30490          0      16838     427032        379          0      10678          0   IO-APIC-fasteoi   vmwgfx, ens34, ens42
    17:     799858          0      68176          0      78056          0      44715          0   IO-APIC-fasteoi   ioc0, ens35, ens43, ens39
    18:       2673          0       6149          0       7651          0       5585          0   IO-APIC-fasteoi   uhci_hcd:usb2, snd_ens1371, ens40, ens44
    19:     145769    1431206          0          0          0          0        305          0   IO-APIC-fasteoi   ehci_hcd:usb1, ens41, ens45, ens33
  </code></pre>
  
  <p>But, sadly, I still found the IRQ is not balanced over the CPUs:</p>
  
  <pre><code>Tasks: 263 total,   2 running, 261 sleeping,   0 stopped,   0 zombie
  %Cpu0  :  7.5 us, 10.0 sy,  0.0 ni, 65.3 id,  0.0 wa,  0.4 hi, 16.7 si,  0.0 st
  %Cpu1  :  9.7 us, 15.0 sy,  0.0 ni, 59.1 id,  0.0 wa,  0.0 hi, 16.2 si,  0.0 st
  %Cpu2  : 11.7 us, 21.6 sy,  0.0 ni, 66.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
  %Cpu3  : 10.4 us, 16.6 sy,  0.0 ni, 66.0 id,  0.0 wa,  0.0 hi,  6.9 si,  0.0 st
  %Cpu4  : 10.9 us, 24.5 sy,  0.0 ni, 64.5 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
  %Cpu5  : 11.8 us, 29.4 sy,  0.0 ni, 58.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
  %Cpu6  :  9.0 us, 19.8 sy,  0.0 ni, 71.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
  %Cpu7  : 11.5 us, 22.6 sy,  0.0 ni, 65.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
  </code></pre>
  
  <p>So, why the IRQs not occur on all CPUs?</p>
  
  <p>How can I balance the irq processing over all CPUs?</p>