Skip to content

Instantly share code, notes, and snippets.

@demofly
Forked from pavel-odintsov/irq_balance_habrahabr.sh
Last active April 3, 2017 09:08
Show Gist options
  • Save demofly/ec0b146a1b62611ac8c3 to your computer and use it in GitHub Desktop.
Save demofly/ec0b146a1b62611ac8c3 to your computer and use it in GitHub Desktop.
IRQ CPU affinity setter: network and RAID hardware
#!/bin/bash
ncpus=`grep -ciw ^processor /proc/cpuinfo`
test "$ncpus" -gt 1 || exit 1
n=0
for irq in `cat /proc/interrupts | grep 'IR-PCI-MSI-edge' | 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=$(echo `printf %x $[2 ** $cpu]` | sed -r 's#(.)(.{8})$#\1,\2#g')
echo "Assign SMP affinity: eth queue $n, irq $irq, cpu $cpu, mask $mask"
echo "echo $mask > $f"
echo "$mask" > "$f"
let n+=1
fi
done
@meteozond
Copy link

what about PCI-MSI-edge ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment