From e458fbb0af969a3aefc9e3c83c3ba6007e6f2708 Mon Sep 17 00:00:00 2001 From: Hadaq Hades Date: Wed, 19 Mar 2014 12:12:23 +0100 Subject: [PATCH] JAM: added advanced cpu affinity setter script by MT --- utils/set_eth_affinity_lxhadeb05.pl | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 utils/set_eth_affinity_lxhadeb05.pl diff --git a/utils/set_eth_affinity_lxhadeb05.pl b/utils/set_eth_affinity_lxhadeb05.pl new file mode 100755 index 0000000..8ff826a --- /dev/null +++ b/utils/set_eth_affinity_lxhadeb05.pl @@ -0,0 +1,52 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Data::Dumper; + +my $fn="/proc/interrupts"; + +open my $fh, "<", $fn || die "could not open $fn for reading"; + +my $rh_i; +for my $cl (<$fh>) { + chomp $cl; + $cl=~s/^\s+//; + my (@s)=split /\s+/, $cl; + #print "i: $s[0] $s[26]\n"; + my $int = $s[0]; + if (defined $int && defined $s[26]) { + $int=~s/://; + $rh_i->{$int} = $s[26]; + } +} + +#print Dumper $rh_i; +my $rh_function = {reverse %$rh_i}; +#print Dumper $rh_function; + +for my $cf (keys %$rh_function) { + my $affinity; + for ($cf) { + if (/eth4-rx/) { + $affinity = "00FF00"; last; + } + if (/eth5-tx/) { + $affinity = "FF0000"; last; + } + if (/eth5-rx/) { + $affinity = "FF0000"; last; + } + $affinity = "NA" + } + + if ($affinity ne "NA") { + my $pfn = "/proc/irq/$rh_function->{$cf}/smp_affinity"; + open my $wh, ">", $pfn or die "could not open file"; + print "/proc/irq/" . $rh_function->{$cf} . "/smp_affinity" . " -> " . $affinity . "\n"; + print $wh $affinity; + close ($wh); + } +} + + -- 2.43.0