summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/system/irq-affinity.pl34
1 files changed, 26 insertions, 8 deletions
diff --git a/scripts/system/irq-affinity.pl b/scripts/system/irq-affinity.pl
index 2f023b7a..409eb8f6 100755
--- a/scripts/system/irq-affinity.pl
+++ b/scripts/system/irq-affinity.pl
@@ -131,17 +131,31 @@ sub set_rps {
close $f;
}
+# Check if the current if this cpu is in the banned mask
+# Uses environment variable VYATTA_IRQAFFINITY_BANNED_CPUS
+# to mask cpus which irq affinity script should ignore
+sub skip_cpu {
+ my $cpu = shift;
+ my $banned = $ENV{'VYATTA_IRQAFFINITY_BANNED_CPUS'};
+
+ return unless defined($banned); # false
+
+ return ((1 << $cpu) & hex($banned)) != 0;
+}
+
# For multi-queue NIC choose next cpu to be on next core
-# FIXME assumes all cpu's online
sub next_cpu {
- my $cpu = shift;
+ my $origcpu = shift;
my $threads = threads_per_core();
+ my $cpu = $origcpu;
- $cpu += $threads;
- if ( $cpu >= $cpus ) {
- # wraparound to next thread on core 0
- $cpu = ($cpu + 1) % $threads;
- }
+ do {
+ $cpu += $threads;
+ if ( $cpu >= $cpus ) {
+ # wraparound to next thread on core 0
+ $cpu = ($cpu + 1) % $threads;
+ }
+ } while ($cpu != $origcpu && skip_cpu($cpu));
return $cpu;
}
@@ -157,11 +171,15 @@ sub choose_cpu {
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.
my $ht_wrap = (($ifunit * $threads) / $cpus) % $threads;
- return ((($ifunit * $threads) + $ht_wrap) % $cpus);
+ my $cpu = ((($ifunit * $threads) + $ht_wrap) % $cpus);
+
+ $cpu = next_cpu($cpu) if skip_cpu($cpu);
+ return $cpu;
}
# Assignment for multi-queue NICs