Skip to content

Commit

Permalink
perf/trace/scripting: rw-by-pid script cleanup
Browse files Browse the repository at this point in the history
Some minor fixes for the rw-by-pid script:

- Fix nuisance 'use of uninitialized value' warnings

- Change the failed read/write sections to sort by error counts

Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
LKML-Reference: <1273466820-9330-3-git-send-email-tzanussi@gmail.com>
Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Tom Zanussi authored and Arnaldo Carvalho de Melo committed May 10, 2010
1 parent c3f5fd2 commit 6922c3d
Showing 1 changed file with 37 additions and 23 deletions.
60 changes: 37 additions & 23 deletions tools/perf/scripts/perl/rw-by-pid.pl
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ sub trace_end
printf("%6s %-20s %10s %10s %10s\n", "------", "--------------------",
"-----------", "----------", "----------");

foreach my $pid (sort {$reads{$b}{bytes_read} <=>
$reads{$a}{bytes_read}} keys %reads) {
my $comm = $reads{$pid}{comm};
my $total_reads = $reads{$pid}{total_reads};
my $bytes_requested = $reads{$pid}{bytes_requested};
my $bytes_read = $reads{$pid}{bytes_read};
foreach my $pid (sort { ($reads{$b}{bytes_read} || 0) <=>
($reads{$a}{bytes_read} || 0) } keys %reads) {
my $comm = $reads{$pid}{comm} || "";
my $total_reads = $reads{$pid}{total_reads} || 0;
my $bytes_requested = $reads{$pid}{bytes_requested} || 0;
my $bytes_read = $reads{$pid}{bytes_read} || 0;

printf("%6s %-20s %10s %10s %10s\n", $pid, $comm,
$total_reads, $bytes_requested, $bytes_read);
Expand All @@ -96,28 +96,35 @@ sub trace_end
printf("%6s %20s %6s %10s\n", "------", "--------------------",
"------", "----------");

foreach my $pid (keys %reads) {
my $comm = $reads{$pid}{comm};
foreach my $err (sort {$reads{$b}{comm} cmp $reads{$a}{comm}}
keys %{$reads{$pid}{errors}}) {
my $errors = $reads{$pid}{errors}{$err};
my @errcounts = ();

printf("%6d %-20s %6d %10s\n", $pid, $comm, $err, $errors);
foreach my $pid (keys %reads) {
foreach my $error (keys %{$reads{$pid}{errors}}) {
my $comm = $reads{$pid}{comm} || "";
my $errcount = $reads{$pid}{errors}{$error} || 0;
push @errcounts, [$pid, $comm, $error, $errcount];
}
}

@errcounts = sort { $b->[3] <=> $a->[3] } @errcounts;

for my $i (0 .. $#errcounts) {
printf("%6d %-20s %6d %10s\n", $errcounts[$i][0],
$errcounts[$i][1], $errcounts[$i][2], $errcounts[$i][3]);
}

printf("\nwrite counts by pid:\n\n");

printf("%6s %20s %10s %10s\n", "pid", "comm",
"# writes", "bytes_written");
printf("%6s %-20s %10s %10s\n", "------", "--------------------",
"-----------", "----------");

foreach my $pid (sort {$writes{$b}{bytes_written} <=>
$writes{$a}{bytes_written}} keys %writes) {
my $comm = $writes{$pid}{comm};
my $total_writes = $writes{$pid}{total_writes};
my $bytes_written = $writes{$pid}{bytes_written};
foreach my $pid (sort { ($writes{$b}{bytes_written} || 0) <=>
($writes{$a}{bytes_written} || 0)} keys %writes) {
my $comm = $writes{$pid}{comm} || "";
my $total_writes = $writes{$pid}{total_writes} || 0;
my $bytes_written = $writes{$pid}{bytes_written} || 0;

printf("%6s %-20s %10s %10s\n", $pid, $comm,
$total_writes, $bytes_written);
Expand All @@ -129,16 +136,23 @@ sub trace_end
printf("%6s %20s %6s %10s\n", "------", "--------------------",
"------", "----------");

foreach my $pid (keys %writes) {
my $comm = $writes{$pid}{comm};
foreach my $err (sort {$writes{$b}{comm} cmp $writes{$a}{comm}}
keys %{$writes{$pid}{errors}}) {
my $errors = $writes{$pid}{errors}{$err};
@errcounts = ();

printf("%6d %-20s %6d %10s\n", $pid, $comm, $err, $errors);
foreach my $pid (keys %writes) {
foreach my $error (keys %{$writes{$pid}{errors}}) {
my $comm = $writes{$pid}{comm} || "";
my $errcount = $writes{$pid}{errors}{$error} || 0;
push @errcounts, [$pid, $comm, $error, $errcount];
}
}

@errcounts = sort { $b->[3] <=> $a->[3] } @errcounts;

for my $i (0 .. $#errcounts) {
printf("%6d %-20s %6d %10s\n", $errcounts[$i][0],
$errcounts[$i][1], $errcounts[$i][2], $errcounts[$i][3]);
}

print_unhandled();
}

Expand Down

0 comments on commit 6922c3d

Please sign in to comment.