-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathset_irq_affinity_cpulist.sh
executable file
·66 lines (58 loc) · 1.41 KB
/
set_irq_affinity_cpulist.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /bin/bash
if [ -z $2 ]; then
echo "usage: $0 <cpu list> <interface or IB device> "
echo " <cpu list> can be either a comma separated list of single core numbers (0,1,2,3) or core groups (0-3)"
exit 1
fi
cpulist=$1
interface=$2
NCPUS=$(cat /proc/cpuinfo | grep -c processor)
ONLINE_CPUS=$(cat /proc/cpuinfo | grep processor | cut -d ":" -f 2)
source common_irq_affinity.sh
IRQS=$( get_irq_list $interface )
if [ -z "$IRQS" ] ; then
echo No IRQs found for $interface.
exit 1
fi
CORES=$( echo $cpulist | sed 's/,/ /g' | wc -w )
for word in $(seq 1 $CORES)
do
SEQ=$(echo $cpulist | cut -d "," -f $word | sed 's/-/ /')
if [ "$(echo $SEQ | wc -w)" != "1" ]; then
CPULIST="$CPULIST $( echo $(seq $SEQ) | sed 's/ /,/g' )"
fi
done
if [ "$CPULIST" != "" ]; then
cpulist=$(echo $CPULIST | sed 's/ /,/g')
fi
CORES=$( echo $cpulist | sed 's/,/ /g' | wc -w )
echo Discovered irqs for $interface: $IRQS
I=1
for IRQ in $IRQS
do
core_id=$(echo $cpulist | cut -d "," -f $I)
online=1
if [ $core_id -ge $NCPUS ]
then
online=0
for online_cpu in $ONLINE_CPUS
do
if [ "$online_cpu" == "$core_id" ]
then
online=1
break
fi
done
fi
if [ $online -eq 0 ]
then
echo "irq $IRQ: Error - core $core_id does not exist"
else
echo Assign irq $IRQ core_id $core_id
affinity=$( core_to_affinity $core_id )
set_irq_affinity $IRQ $affinity
fi
I=$(( (I%CORES) + 1 ))
done
echo
echo done.