Skip to content

Instantly share code, notes, and snippets.

@evgenypim
Forked from pavel-odintsov/irq_balance_habrahabr.sh
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save evgenypim/51dbb8dcf5155195dcb6 to your computer and use it in GitHub Desktop.

Select an option

Save evgenypim/51dbb8dcf5155195dcb6 to your computer and use it in GitHub Desktop.

Revisions

  1. @pavel-odintsov pavel-odintsov created this gist Jun 25, 2015.
    20 changes: 20 additions & 0 deletions irq_balance_habrahabr.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/bin/bash

    # from http://habrahabr.ru/post/108240/
    ncpus=`grep -ciw ^processor /proc/cpuinfo`
    test "$ncpus" -gt 1 || exit 1

    n=0
    for irq in `cat /proc/interrupts | grep eth | awk '{print $1}' | sed s/\://g`
    do
    f="/proc/irq/$irq/smp_affinity"
    test -r "$f" || continue
    cpu=$[$ncpus - ($n % $ncpus) - 1]
    if [ $cpu -ge 0 ]
    then
    mask=`printf %x $[2 ** $cpu]`
    echo "Assign SMP affinity: eth queue $n, irq $irq, cpu $cpu, mask 0x$mask"
    echo "$mask" > "$f"
    let n+=1
    fi
    done