Skip to content

Instantly share code, notes, and snippets.

@TeTeHacko
Created October 8, 2018 12:34
Show Gist options
  • Save TeTeHacko/f0d52f77e1e38ddd9a9dbc62f7e134cd to your computer and use it in GitHub Desktop.
Save TeTeHacko/f0d52f77e1e38ddd9a9dbc62f7e134cd to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Author: Tomas Herceg <[email protected]>
# Fixed irqbalancing maping for eth and sas, because sometimes irqbalance sucks
[ "$1" == "debug" ] && debug=true || debug=false
$debug && set -x
systemctl disable irqbalance &>/dev/null
systemctl stop irqbalance &>/dev/null
irqbalance --oneshot --foreground
$debug && set +x
tot=`cat /proc/interrupts |grep 'eth[0-9]\{1,\}-' |wc -l`
cpus=`grep -c ^processor /proc/cpuinfo`
num=$(( tot / cpus ))
[ $num -le 0 ] && num=1
i=0
j=0
$debug && echo total network interupts: $tot
$debug && echo total cpus: $cpus
$debug && echo interpupt per core: $num
for int in `cat /proc/interrupts |grep 'eth[0-9]\{1,\}-' |cut -f1 -d':'`; do
b=`echo "obase=16; 2 ^ $j" | bc`
echo $b > /proc/irq/$int/smp_affinity
$debug && echo CPU:$j irq:$int
i=$((i + 1))
if [ $i -eq $num ]; then
i=0
j=$((j + 1))
fi
done
for int in `cat /proc/interrupts |grep 'sas' |cut -f1 -d':'`; do
b=`echo "obase=16; 2 ^ $j" | bc`
echo $b > /proc/irq/$int/smp_affinity
$debug && echo CPU:$j irq:$int
i=$((i + 1))
if [ $i -eq $num ]; then
i=0
j=$((j + 1))
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment