Forked from pavel-odintsov/irq_balance_habrahabr.sh
Last active
August 29, 2015 19:20
-
-
Save metajiji/33d32f0dedb49a512a0e to your computer and use it in GitHub Desktop.
irq_balance_habrahabr.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# checkbashisms irq_balance_habrahabr_POSIX.sh | |
# from http://habrahabr.ru/post/108240/ | |
ncpus=$(grep -ciw ^processor /proc/cpuinfo) | |
[ $ncpus -gt 1 ] || exit 1 | |
n=0 | |
for irq in `awk '/eth/{gsub(":","",$0);print $1}' /proc/interrupts`; do | |
f="/proc/irq/$irq/smp_affinity" | |
[ -w "$f" ] || continue | |
cpu=$(($ncpus-($n%$ncpus)-1)) | |
if [ $cpu -ge 0 ]; then | |
mask=$(printf %x $(echo $cpu | awk '{print 2^$0}')) | |
echo "Assign SMP affinity: eth queue $n, irq $irq, cpu $cpu, mask 0x$mask" | |
echo "$mask" > "$f" | |
n=$(($n+1)) | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now POSIX compliant.