Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brammittendorff/4c51c1aba285e9d4d47e0b5cfa558966 to your computer and use it in GitHub Desktop.
Save brammittendorff/4c51c1aba285e9d4d47e0b5cfa558966 to your computer and use it in GitHub Desktop.
irq_balance_habrahabr.sh
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment