]> jspc29.x-matter.uni-frankfurt.de Git - hadesdaq.git/commitdiff
JAM: added advanced cpu affinity setter script by MT
authorHadaq Hades <hadaq@lxhadesdaq>
Wed, 19 Mar 2014 11:12:23 +0000 (12:12 +0100)
committerHadaq Hades <hadaq@lxhadesdaq>
Wed, 19 Mar 2014 11:12:23 +0000 (12:12 +0100)
utils/set_eth_affinity_lxhadeb05.pl [new file with mode: 0755]

diff --git a/utils/set_eth_affinity_lxhadeb05.pl b/utils/set_eth_affinity_lxhadeb05.pl
new file mode 100755 (executable)
index 0000000..8ff826a
--- /dev/null
@@ -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);
+  }
+}
+
+