| 1 |
#!/bin/sh |
| 2 |
# Do not edit this file, create your own policy script and make it |
| 3 |
# executable for irqbalance process, you can use this file as an |
| 4 |
# boilerplate. |
| 5 |
|
| 6 |
SYS_DEV_PATH=$1 |
| 7 |
IRQ_NUM=$2 |
| 8 |
|
| 9 |
IRQ_PATH=/proc/irq/$IRQ_NUM |
| 10 |
UEVENT_FILE=$SYS_DEV_PATH/uevent |
| 11 |
|
| 12 |
# Scripts below is an example for banning certain IRQs from |
| 13 |
# irqbalance and strictly apply their affinity_hint setting |
| 14 |
[[ ! -e $UEVENT_FILE ]] && exit 1 |
| 15 |
|
| 16 |
# IRQs from following drivers will be handled by this script |
| 17 |
# Driver names should be separated by space |
| 18 |
AFFINITY_WHITELIST="" |
| 19 |
|
| 20 |
while read line; do |
| 21 |
if [[ $line == "DRIVER="* ]] && \ |
| 22 |
[[ " $AFFINITY_WHITELIST " == *" ${line#DRIVER=} "* ]]; then |
| 23 |
affinity_hint=$(cat $IRQ_PATH/affinity_hint 2>/dev/null) |
| 24 |
# Check if affinity_hint value have at least one bit set |
| 25 |
if [[ ! "$affinity_hint" =~ ^[0,]*$ ]]; then |
| 26 |
# Ban it from irqbalance so it won't get balanced, |
| 27 |
# we'll follow its affinity_hint setting |
| 28 |
echo "ban=true" |
| 29 |
# If the affinity_hint value is valid, kernel would set |
| 30 |
# the same value for smp_affinity. But force to set that |
| 31 |
# again in case the IRQ was balanced before. |
| 32 |
echo "$affinity_hint" > $IRQ_PATH/smp_affinity |
| 33 |
# Stop further script processing |
| 34 |
exit 0 |
| 35 |
fi |
| 36 |
fi |
| 37 |
done <<< "$(cat $UEVENT_FILE)" |
| 38 |
|
| 39 |
exit 1 |