summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2011-05-20 11:08:20 -0700
committerStephen Hemminger <shemminger@vyatta.com>2011-05-20 11:09:55 -0700
commitc6430d1e9b511e36f59b5b5a484b7edf829be117 (patch)
treee7b568766866c403139cf71ea46040bae9c4618c
parentc206df7d62af7b1c2f310e546c877c18095bc6d1 (diff)
downloadvyatta-cfg-quagga-c6430d1e9b511e36f59b5b5a484b7edf829be117.tar.gz
vyatta-cfg-quagga-c6430d1e9b511e36f59b5b5a484b7edf829be117.zip
irq-affinity: more fixup
1. Fix thread_per_core -- now a global variable 2. Add documentation about where still broken with offline cpus 3. Break out hamming weight function (might be used to fix #2) Tested on UP, 4 core x 2 thread, 8 socket (virt) and Multiqueue and single queue NIC.
-rwxr-xr-xscripts/system/irq-affinity.pl22
1 files changed, 14 insertions, 8 deletions
diff --git a/scripts/system/irq-affinity.pl b/scripts/system/irq-affinity.pl
index 79bf7d58..de0c3099 100755
--- a/scripts/system/irq-affinity.pl
+++ b/scripts/system/irq-affinity.pl
@@ -93,6 +93,16 @@ sub irqinfo {
return $irqmap;
}
+# compute number of bits set
+sub hweight {
+ my $bits = shift;
+ my $count = 0;
+
+ for (; $bits > 0; $bits >>= 1) {
+ ++$count if ($bits & 1);
+ }
+ return $count;
+}
# count the bits set in a mapping file
sub path_sibling {
@@ -107,11 +117,7 @@ sub path_sibling {
chomp $line;
for my $mask (split(/,/, $line)) {
- my $bits = hex($mask);
-
- for (; $bits > 0; $bits /= 2) {
- ++$result if ($bits & 1);
- }
+ $result += hweight(hex($mask));
}
return $result;
@@ -124,6 +130,7 @@ sub path_sibling {
sub cpuinfo {
my $cpu = 0;
+ # XXX doesn't handle offline CPU's...
while ( -e $PATH_SYS_SYSTEM . '/cpu/cpu' . $cpu ) {
++$cpu;
}
@@ -182,6 +189,7 @@ sub skip_cpu {
}
# For multi-queue NIC choose next cpu to be on next core
+# XXX doesn't handle offline CPU's...
sub next_cpu {
my $origcpu = shift;
my $cpu = $origcpu;
@@ -207,11 +215,10 @@ sub choose_cpu {
die "can't find number for $ifname\n"
unless defined($ifunit);
- my $threads = threads_per_core();
-
# Give the load first to one CPU of each hyperthreaded core, then
# if there are enough NICs, give the load to the other CPU of
# each core.
+ # XXX doesn't handle offline CPU's...
my $ht_wrap = (($ifunit * $threads) / $cpus) % $threads;
my $cpu = ((($ifunit * $threads) + $ht_wrap) % $cpus);
@@ -273,7 +280,6 @@ sub assign_single {
set_affinity( $ifname, $irq, 1 << $cpu );
- my $threads = threads_per_core();
if ($threads > 1) {
# Use both threads on this cpu if hyperthreading
my $mask = ((1 << $threads) - 1) << $cpu;