From 3e59f81ea589d3d4b342849b01df4a5cb48ee5a4 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 9 Feb 2015 09:26:10 +0000 Subject: [PATCH] scripts/spread-mlx4-ib-interrupts: Add to repository git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6027 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scripts/spread-mlx4-ib-interrupts | 55 +++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 scripts/spread-mlx4-ib-interrupts diff --git a/scripts/spread-mlx4-ib-interrupts b/scripts/spread-mlx4-ib-interrupts new file mode 100755 index 000000000..6c61766df --- /dev/null +++ b/scripts/spread-mlx4-ib-interrupts @@ -0,0 +1,55 @@ +#!/bin/awk -f + +BEGIN { + if (debug != "") + print "[, ]: "; + "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' 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 +}