| #!/bin/sh |
| # Do not edit this file, create your own policy script and make it |
| # executable for irqbalance process, you can use this file as an |
| # boilerplate. |
| |
| SYS_DEV_PATH=$1 |
| IRQ_NUM=$2 |
| |
| IRQ_PATH=/proc/irq/$IRQ_NUM |
| UEVENT_FILE=$SYS_DEV_PATH/uevent |
| |
| # Scripts below is an example for banning certain IRQs from |
| # irqbalance and strictly apply their affinity_hint setting |
| [[ ! -e $UEVENT_FILE ]] && exit 1 |
| |
| # IRQs from following drivers will be handled by this script |
| # Driver names should be separated by space |
| AFFINITY_WHITELIST="" |
| |
| while read line; do |
| if [[ $line == "DRIVER="* ]] && \ |
| [[ " $AFFINITY_WHITELIST " == *" ${line#DRIVER=} "* ]]; then |
| affinity_hint=$(cat $IRQ_PATH/affinity_hint 2>/dev/null) |
| # Check if affinity_hint value have at least one bit set |
| if [[ ! "$affinity_hint" =~ ^[0,]*$ ]]; then |
| # Ban it from irqbalance so it won't get balanced, |
| # we'll follow its affinity_hint setting |
| echo "ban=true" |
| # If the affinity_hint value is valid, kernel would set |
| # the same value for smp_affinity. But force to set that |
| # again in case the IRQ was balanced before. |
| echo "$affinity_hint" > $IRQ_PATH/smp_affinity |
| # Stop further script processing |
| exit 0 |
| fi |
| fi |
| done <<< "$(cat $UEVENT_FILE)" |
| |
| exit 1 |