-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathset_irq_affinity_bynode.sh
executable file
·82 lines (71 loc) · 1.91 KB
/
set_irq_affinity_bynode.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! /bin/bash
if [ -z $2 ]; then
echo "usage: $0 <node id> <interface or IB device> [2nd interface or IB device]"
exit 1
fi
source common_irq_affinity.sh
node=$1
interface=$2
interface2=$3
IRQS=$( get_irq_list $interface )
if [ -z "$IRQS" ] ; then
echo No IRQs found for $interface.
exit 1
fi
echo Discovered irqs for $interface: $IRQS
if [ $interface2 ]; then
IRQS_2=$( get_irq_list $interface2 )
if [ -z "$IRQS_2" ] ; then
echo No IRQs found for $interface2.
exit 1
fi
echo Discovered irqs for $interface2: $IRQS_2
echo "---------------------------------------"
echo "Optimizing IRQs for Dual port traffic"
echo "---------------------------------------"
else
echo "-------------------------------------"
echo "Optimizing IRQs for Single port traffic"
echo "-------------------------------------"
fi
cpulist=$(cat /sys/devices/system/node/node$node/cpulist )
if [ "$(echo $?)" != "0" ]; then
echo "Node id '$node' does not exists."
exit
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 )
I=1
for IRQ in $IRQS
do
core_id=$(echo $cpulist | cut -d "," -f $I)
echo Assign irq $IRQ core_id $core_id
affinity=$( core_to_affinity $core_id )
set_irq_affinity $IRQ $affinity
if [ -z $interface2 ]; then
I=$(( (I%CORES) + 1 ))
else
I=$(( (I%(CORES/2)) + 1 ))
fi
done
I=$(( (CORES/2) + 1 ))
for IRQ in $IRQS_2
do
core_id=$(echo $cpulist | cut -d "," -f $I)
echo Assign irq $IRQ core_id $core_id
affinity=$( core_to_affinity $core_id )
set_irq_affinity $IRQ $affinity
I=$(( (I%(CORES/2)) + 1 + (CORES/2) ))
done
echo
echo done.