Files
scst/scripts/spread-mlx4-ib-interrupts
Bart Van Assche 74e73e3694 Merge trunk r6221 into iser branch
git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/iser@6222 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2015-06-09 00:32:21 +00:00

56 lines
1.8 KiB
Awk
Executable File

#!/bin/awk -f
BEGIN {
if (debug != "")
print "[<node>, <per_node_cpu_idx>]: <cpu>";
"ls -1d /sys/devices/system/node/node* 2>&1 | wc -l" | getline nodes
if (nodes > 1) {
for (i = 0; i < nodes; i++) {
cpus_per_node = 0
while (("cd /sys/devices/system/cpu && ls -d cpu*/node" i " | sed 's/^cpu//;s,/.*,,'|sort -n" | getline j) > 0) {
if (debug != "")
print "[" i ", " cpus_per_node "]: " j
cpu[i, cpus_per_node++] = j
}
}
} else {
cpus_per_node = 0
while (("cd /sys/devices/system/cpu && ls -d cpu[0-9]* | sed 's/^cpu//'|sort -n" | getline j) > 0) {
if (debug != "")
print "[0, " cpus_per_node "]: " j
cpu[0, cpus_per_node++] = j
}
}
for (i = 0; i < nodes; i++)
nextcpu[i] = 0
while (("sed -n 's/.*mlx4-ib-\\([0-9]*\\)-[0-9]*@\\(.*\\)$/\\1 \\2/p' /proc/interrupts | uniq" | getline) > 0) {
port = $1
bus = substr($0, length($1) + 2)
if (debug != "")
print "HCA port = " port "; bus = " bus
irqcount = 0
while (("sed -n 's/^[[:blank:]]*\\([0-9]*\\):[0-9[:blank:]]*[^[:blank:]]*[[:blank:]]*\\(mlx4-ib-" port "-[0-9]*@" bus "\\)$/\\1 \\2/p' </proc/interrupts" | getline) > 0) {
irq[irqcount] = $1
irqname[irqcount] = substr($0, length($1) + 2)
irqcount++
}
for (i = 0; i < nodes; i++) {
ch_start = i * irqcount / nodes
ch_end = (i + 1) * irqcount / nodes
for (ch = ch_start; ch < ch_end; ch++) {
c = cpu[i, nextcpu[i]++ % cpus_per_node]
if (nodes > 1)
nodetxt = " (node " i ")"
else
nodetxt = ""
print "IRQ " irq[ch] " (" irqname[ch] "): CPU " c nodetxt
cmd="echo " c " >/proc/irq/" irq[ch] "/smp_affinity_list"
if (debug != "")
print cmd
system(cmd)
}
}
}
exit 0
}