Last step, how to offload the interrupts from the isolated CPU. These steps are executed at boot time.
First, check that irqbalance is not active on the system (it is not active on groovyarcade)
Back to previous example with isolation of CPU1, we will change the smp_affinity on this cpu.
We have to compute the CPU bit position (CPUPOS) and the isolation mask (MASK).
SINGLE_CPU=1
MASK=`perl -e '$val=$ARGV[0];$new=0xFF & ~(1<<$val);printf "%02x\n",$new;' ${SINGLE_CPU}`
CPUPOS=`perl -e '$val=$ARGV[0];$new=1<<$val;printf "%02x\n",$new;' ${SINGLE_CPU}`
First we exclude the CPU from the default affinity.
echo $MASK > /proc/irq/default_smp_affinity
Now for each interrupts (some interrupt, like 0,2... are not movable). We remove cpu1 from the set and in case it was the unique cpu, we move it to cpu0. Iy is easier to create a script and process the changes using xargs.
find /proc/irq/ -name 'smp_affinity' -print0 | xargs -0 -I'{}' ./your_irq_script.sh ${SINGLE_CPU} "{}"
OLD=`cat $2`
MASK=`perl -e '$val=$ARGV[0];$new=0xFF & ~(1<<$val);printf "%02x\n",$new;' ${SINGLE_CPU}`
CPUPOS=`perl -e '$val=$ARGV[0];$new=1<<$val;printf "%02x\n",$new;' ${SINGLE_CPU}`
NEW=`perl -e '$val=hex($ARGV[0]);$mask=hex($ARGV[1]);$new=$val & $mask;if($new == 0 ) { print "01\n"; } elsif ($val != $new) {printf "%02x\n",$new;}' $OLD $MASK`
if ( test -n "$NEW" ) then
ID=`echo $2 | sed 's+.*irq/\([0-9]*\)/smp.*.*+\1+'`
if ( test "$ID" -gt 2 ) then
echo $NEW > $2
fi
fi
I have intentionally not optimized the previous script and commands sequences.
You can check interruptions on each cpu by doing a cat /proc/interrupts