From d9396f80087fb464f43c56b84c7fc9c7fb8018b7 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 25 Feb 2011 09:05:51 -0800 Subject: Don't set irq affinity if device is disabled Bug 6784 No point in trying to force affinity if device is offline. (cherry picked from commit b541f5ffa7bf1c6951e01ae4814e0cd38adc42d5) --- scripts/system/irq-affinity.pl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/system/irq-affinity.pl b/scripts/system/irq-affinity.pl index 99d37bbc..23da4635 100755 --- a/scripts/system/irq-affinity.pl +++ b/scripts/system/irq-affinity.pl @@ -39,6 +39,19 @@ if ($mask eq 'auto') { exit 0; +# Test if device is in up by reading /sys/class/net/ethX/flags +sub is_up { + my $ifname = shift; + + open ( my $f, '<', "/sys/class/net/$ifname/flags" ) + or return; + my $flags = <$f>; + chomp $flags; + close $f; + + return hex($flags) & 1; +} + # Get current irq assignments by reading /proc/interrupts sub irqinfo { my $irqmap; @@ -252,6 +265,8 @@ sub affinity_mask { check_mask($ifname, "irq", $irqmsk); check_mask($ifname, "rps", $rpsmsk) if $rpsmsk; + return unless is_up($ifname); + my $irq = get_irq($ifname); die "$ifname: attempt to assign affinity to device without irq\n" unless (defined($irq)); @@ -275,6 +290,9 @@ sub affinity_mask { # CPUs available to do that. sub affinity_auto { my $ifname = shift; + + return unless is_up($ifname); + my $irqmap = irqinfo(); my @irqnames = keys %{$irqmap}; -- cgit v1.2.3