cpuhotplug_report_proc_interrupts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/perl
  2. use strict;
  3. sub compare_proc_interrupts {
  4. my ($run1, $run2) = @_;
  5. my $printed_header;
  6. foreach my $irq (sort keys %{$run1}) {
  7. if (! $printed_header) {
  8. printf "%-8s ", "IRQ";
  9. foreach my $cpu (sort keys %{$run1->{$irq}}) {
  10. printf "%-5s ", $cpu;
  11. }
  12. print "\n";
  13. $printed_header = 1;
  14. }
  15. printf "%-8s ", $irq;
  16. foreach my $cpu (sort keys %{$run1->{$irq}}) {
  17. printf "%-5s ", $run2->{$irq}->{$cpu} - $run1->{$irq}->{$cpu};
  18. }
  19. print "\n";
  20. }
  21. }
  22. sub parse_proc_interrupts {
  23. my $content = shift;
  24. my @cpus;
  25. my %run;
  26. foreach my $line (split /\n/, $content) {
  27. $line =~ s/^\s+//;
  28. $line =~ s/\s+$//;
  29. if (! @cpus) {
  30. @cpus = split /\s+/, $line;
  31. } else {
  32. my @items = split /\s+/, $line;
  33. my $irq = shift @items;
  34. $irq =~ s/:$//;
  35. foreach my $cpu (@cpus) {
  36. $run{"IRQ$irq"}->{"$cpu"} = shift @items;
  37. }
  38. }
  39. }
  40. return \%run;
  41. }
  42. my $run1 = parse_proc_interrupts(shift @ARGV);
  43. my $run2 = parse_proc_interrupts(shift @ARGV);
  44. compare_proc_interrupts($run1, $run2);