Skip to content

Instantly share code, notes, and snippets.

@jschaub30
Created June 15, 2015 16:15
Show Gist options
  • Save jschaub30/d9e98bd7cd8b6af6b98b to your computer and use it in GitHub Desktop.
Save jschaub30/d9e98bd7cd8b6af6b98b to your computer and use it in GitHub Desktop.
Bash script to set network interrupts in Ubuntu linux
#!/bin/bash
[[ $# -lt 1 ]] && echo "Usage: $0 [INTERFACE] [RESET]" && exit 1
IFACE=$1
# Tweak the CPUSTART to fit your system
CPUSTART=32
[[ $IFACE == "eth2" ]] && CPUSTART=8
[[ $IFACE == "eth3" ]] && CPUSTART=16
[[ $IFACE == "eth4" ]] && CPUSTART=24
THREAD=0
cat /proc/interrupts | grep "$IFACE-" | cut -d':' -f1 > tmp.interfaces
for IRQ in $(cat tmp.interfaces)
do
if [[ $2 == 'RESET' ]]
then
CMD="echo '0-159' > /proc/irq/$IRQ/smp_affinity_list"
else
CPU=$(( CPUSTART + THREAD ))
CMD="echo $CPU > /proc/irq/$IRQ/smp_affinity_list"
fi
echo sudo bash -c "$CMD"
sudo bash -c "$CMD"
THREAD=$(($THREAD+1))
done
./read_interrupts.sh $IFACE # see https://gist.github.com/jschaub30/9f9d9f54d3ee6f53d2b3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment