diff options
Diffstat (limited to 'set_irq_affinity.sh')
-rwxr-xr-x | set_irq_affinity.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/set_irq_affinity.sh b/set_irq_affinity.sh new file mode 100755 index 0000000..fbf8fa4 --- /dev/null +++ b/set_irq_affinity.sh @@ -0,0 +1,45 @@ +#!/system/bin/sh + +# This script sets the default affinity to the processors with the given part id. +# - part id is in hex (as seen in /proc/cpuinfo) + +function build_mask_from_part_id { + local IFS + local mask + local ref_part_id + + ref_part_id=$1 + IFS=$'\n' + + for line in `cat /proc/cpuinfo` + do + IFS=':' + set -A tokens $line + + if [ "${line#'processor'}" != "$line" ] + then + cpu="${tokens[1]##' '}" + elif [ "${line#'CPU part'}" != "$line" ] + then + part_id="${tokens[1]##' '}" + + if [ "$part_id" == "$ref_part_id" ] + then + (( mask |= 1 << $cpu )) + fi + fi + done + echo $(printf "%x" $mask) +} + +ref_part_id=$(echo $1 | tr '[A-Z]' '[a-z]') +mask=$(build_mask_from_part_id $ref_part_id) +[ -z "$mask" ] && exit + +echo $mask > /proc/irq/default_smp_affinity + +for i in `ls /proc/irq` +do + affinity_file="/proc/irq/$i/smp_affinity" + [ -e $affinity_file ] && echo $mask > $affinity_file +done |