diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2011-05-03 16:23:56 -0700 |
---|---|---|
committer | Stephen Hemminger <shemminger@vyatta.com> | 2011-05-03 16:25:13 -0700 |
commit | 535f1748b0b74f33a5bdc471be35490f1f005834 (patch) | |
tree | 5a29010ffd8630db2f31a00b8ec789b0a8d6077c | |
parent | 8fd927582a1f1de13a172400d97a520a3fc76ce4 (diff) | |
download | vyatta-cfg-system-535f1748b0b74f33a5bdc471be35490f1f005834.tar.gz vyatta-cfg-system-535f1748b0b74f33a5bdc471be35490f1f005834.zip |
Make irq affinity handle any irq naming convention
Bug 7032 (reprise)
Since there are various forms of multi-queue naming, it is better
to just go with the simplest pattern which is to take all the irq's
of form ethX-... and sort them.
-rwxr-xr-x | scripts/system/irq-affinity.pl | 66 |
1 files changed, 26 insertions, 40 deletions
diff --git a/scripts/system/irq-affinity.pl b/scripts/system/irq-affinity.pl index fa8e770a..a1c0793c 100755 --- a/scripts/system/irq-affinity.pl +++ b/scripts/system/irq-affinity.pl @@ -171,26 +171,25 @@ sub first_cpu { } # Assignment for multi-queue NICs -# Assign each queue to successive cores sub assign_multiqueue { - my ( $ifname, $numq, $irqmap, $irqfmt ) = @_; + my $ifname = shift; + my $irqmap = shift; + my $numq = $#_; my $cpu = first_cpu($ifname, $numq); - for ( my $q = 0 ; $q < $numq ; $q++ ) { - # handles multiple irq's per interface (tx/rx) - foreach my $fmt (@$irqfmt) { - my $name = sprintf( $fmt, $ifname, $q ); - my $irq = $irqmap->{$name}; + foreach my $name (sort @_) { + my $irq = $irqmap->{$name}; - syslog(LOG_INFO, "%s: queue %d assign %s to cpu %d", - $ifname, $q, $name, $cpu ); + die "Can't find irq in map for $name\n" unless $irq; - # Assign CPU affinity for both IRQs - set_affinity( $ifname, $irq, 1 << $cpu ); + syslog(LOG_INFO, "%s: assign %s to cpu %d", + $ifname, $name, $cpu ); - # TODO use RPS to steer data if cores > queues? - } - $cpu = next_cpu($cpu); + # Assign CPU affinity for both IRQs + set_affinity( $ifname, $irq, 1 << $cpu ); + + # TODO use RPS to steer data if cores > queues? + $cpu = next_cpu($cpu); } } @@ -253,7 +252,6 @@ sub affinity_mask { set_rps($ifname, 0, hex($rpsmsk)) if $rpsmsk; } - # The auto strategy involves trying to achieve the following goals: # # - Spread the receive load among as many CPUs as possible. @@ -279,33 +277,21 @@ sub affinity_auto { my $irq = $irqmap->{$ifname}; assign_single( $ifname, $irq) if $irq; } elsif ($numirq > 1) { - - # Match seperate irq for Rx and Tx - my $nrx = grep { /^$ifname-rx-/ } @irqnames; - if ( $nrx > 0 ) { - my $ntx = grep { /^$ifname-tx-/ } @irqnames; - die "$ifname: rx queues $nrx != tx queues $ntx" - unless ( $nrx == $ntx ); - - return assign_multiqueue( $ifname, $nrx, $irqmap, - [ '%s-rx-%d', '%s-tx-%d' ] ); - } - - # Match eth0-N form - my $nq = grep { /^$ifname-\d+$/ } @irqnames; - if ( $nq > 0 ) { - return assign_multiqueue( $ifname, $nq, $irqmap, [ '%s-%d' ] ); + # Special case for paired Rx and Tx + my @mirq = grep { /^$ifname-rx-/ } @irqnames; + if ( $#mirq > 0 ) { + assign_multiqueue( $ifname, $irqmap, @mirq ); + + @mirq = grep { /^$ifname-tx-/ } @irqnames; + assing_multiqueue( $ifname, $irqmap, @mirq ); + return; } - # Match eth-sometext-N - if ($irqnames[0] =~ /^$ifname(.*-)\d+$/) { - my $sep = $1; - my $regex = '^' . $ifname . $sep . '\d+$'; - $nq = grep { $regex } @irqnames; - if ( $nq > 0 ) { - return assign_multiqueue( $ifname, $nq, $irqmap, - [ "%s$sep%d" ] ); - } + # Normal case for single irq per queue + @mirq = grep { /^$ifname-/ } @irqnames; + if ( $#mirq > 0 ) { + assign_multiqueue( $ifname, $irqmap, @mirq ); + return; } syslog(LOG_ERR, "%s: Unknown multiqueue irq naming: %s\n", $ifname, |