diff options
author | Tom Zanussi <tzanussi@gmail.com> | 2010-05-10 00:46:53 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-05-10 18:50:55 -0400 |
commit | 6922c3d772711239e75ddaea760e6b0535e7e7a6 (patch) | |
tree | ea34f016551dee09005a71f5f99f8317c81ff22f /tools/perf/scripts | |
parent | c3f5fd287aa897f710f3305367a1d256c9cf3e83 (diff) |
perf/trace/scripting: rw-by-pid script cleanup
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>
Diffstat (limited to 'tools/perf/scripts')
-rw-r--r-- | tools/perf/scripts/perl/rw-by-pid.pl | 60 |
1 files changed, 37 insertions, 23 deletions
diff --git a/tools/perf/scripts/perl/rw-by-pid.pl b/tools/perf/scripts/perl/rw-by-pid.pl index da601fae1a00..9db23c9daf55 100644 --- a/tools/perf/scripts/perl/rw-by-pid.pl +++ b/tools/perf/scripts/perl/rw-by-pid.pl | |||
@@ -79,12 +79,12 @@ sub trace_end | |||
79 | printf("%6s %-20s %10s %10s %10s\n", "------", "--------------------", | 79 | printf("%6s %-20s %10s %10s %10s\n", "------", "--------------------", |
80 | "-----------", "----------", "----------"); | 80 | "-----------", "----------", "----------"); |
81 | 81 | ||
82 | foreach my $pid (sort {$reads{$b}{bytes_read} <=> | 82 | foreach my $pid (sort { ($reads{$b}{bytes_read} || 0) <=> |
83 | $reads{$a}{bytes_read}} keys %reads) { | 83 | ($reads{$a}{bytes_read} || 0) } keys %reads) { |
84 | my $comm = $reads{$pid}{comm}; | 84 | my $comm = $reads{$pid}{comm} || ""; |
85 | my $total_reads = $reads{$pid}{total_reads}; | 85 | my $total_reads = $reads{$pid}{total_reads} || 0; |
86 | my $bytes_requested = $reads{$pid}{bytes_requested}; | 86 | my $bytes_requested = $reads{$pid}{bytes_requested} || 0; |
87 | my $bytes_read = $reads{$pid}{bytes_read}; | 87 | my $bytes_read = $reads{$pid}{bytes_read} || 0; |
88 | 88 | ||
89 | printf("%6s %-20s %10s %10s %10s\n", $pid, $comm, | 89 | printf("%6s %-20s %10s %10s %10s\n", $pid, $comm, |
90 | $total_reads, $bytes_requested, $bytes_read); | 90 | $total_reads, $bytes_requested, $bytes_read); |
@@ -96,16 +96,23 @@ sub trace_end | |||
96 | printf("%6s %20s %6s %10s\n", "------", "--------------------", | 96 | printf("%6s %20s %6s %10s\n", "------", "--------------------", |
97 | "------", "----------"); | 97 | "------", "----------"); |
98 | 98 | ||
99 | foreach my $pid (keys %reads) { | 99 | my @errcounts = (); |
100 | my $comm = $reads{$pid}{comm}; | ||
101 | foreach my $err (sort {$reads{$b}{comm} cmp $reads{$a}{comm}} | ||
102 | keys %{$reads{$pid}{errors}}) { | ||
103 | my $errors = $reads{$pid}{errors}{$err}; | ||
104 | 100 | ||
105 | printf("%6d %-20s %6d %10s\n", $pid, $comm, $err, $errors); | 101 | foreach my $pid (keys %reads) { |
102 | foreach my $error (keys %{$reads{$pid}{errors}}) { | ||
103 | my $comm = $reads{$pid}{comm} || ""; | ||
104 | my $errcount = $reads{$pid}{errors}{$error} || 0; | ||
105 | push @errcounts, [$pid, $comm, $error, $errcount]; | ||
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | @errcounts = sort { $b->[3] <=> $a->[3] } @errcounts; | ||
110 | |||
111 | for my $i (0 .. $#errcounts) { | ||
112 | printf("%6d %-20s %6d %10s\n", $errcounts[$i][0], | ||
113 | $errcounts[$i][1], $errcounts[$i][2], $errcounts[$i][3]); | ||
114 | } | ||
115 | |||
109 | printf("\nwrite counts by pid:\n\n"); | 116 | printf("\nwrite counts by pid:\n\n"); |
110 | 117 | ||
111 | printf("%6s %20s %10s %10s\n", "pid", "comm", | 118 | printf("%6s %20s %10s %10s\n", "pid", "comm", |
@@ -113,11 +120,11 @@ sub trace_end | |||
113 | printf("%6s %-20s %10s %10s\n", "------", "--------------------", | 120 | printf("%6s %-20s %10s %10s\n", "------", "--------------------", |
114 | "-----------", "----------"); | 121 | "-----------", "----------"); |
115 | 122 | ||
116 | foreach my $pid (sort {$writes{$b}{bytes_written} <=> | 123 | foreach my $pid (sort { ($writes{$b}{bytes_written} || 0) <=> |
117 | $writes{$a}{bytes_written}} keys %writes) { | 124 | ($writes{$a}{bytes_written} || 0)} keys %writes) { |
118 | my $comm = $writes{$pid}{comm}; | 125 | my $comm = $writes{$pid}{comm} || ""; |
119 | my $total_writes = $writes{$pid}{total_writes}; | 126 | my $total_writes = $writes{$pid}{total_writes} || 0; |
120 | my $bytes_written = $writes{$pid}{bytes_written}; | 127 | my $bytes_written = $writes{$pid}{bytes_written} || 0; |
121 | 128 | ||
122 | printf("%6s %-20s %10s %10s\n", $pid, $comm, | 129 | printf("%6s %-20s %10s %10s\n", $pid, $comm, |
123 | $total_writes, $bytes_written); | 130 | $total_writes, $bytes_written); |
@@ -129,16 +136,23 @@ sub trace_end | |||
129 | printf("%6s %20s %6s %10s\n", "------", "--------------------", | 136 | printf("%6s %20s %6s %10s\n", "------", "--------------------", |
130 | "------", "----------"); | 137 | "------", "----------"); |
131 | 138 | ||
132 | foreach my $pid (keys %writes) { | 139 | @errcounts = (); |
133 | my $comm = $writes{$pid}{comm}; | ||
134 | foreach my $err (sort {$writes{$b}{comm} cmp $writes{$a}{comm}} | ||
135 | keys %{$writes{$pid}{errors}}) { | ||
136 | my $errors = $writes{$pid}{errors}{$err}; | ||
137 | 140 | ||
138 | printf("%6d %-20s %6d %10s\n", $pid, $comm, $err, $errors); | 141 | foreach my $pid (keys %writes) { |
142 | foreach my $error (keys %{$writes{$pid}{errors}}) { | ||
143 | my $comm = $writes{$pid}{comm} || ""; | ||
144 | my $errcount = $writes{$pid}{errors}{$error} || 0; | ||
145 | push @errcounts, [$pid, $comm, $error, $errcount]; | ||
139 | } | 146 | } |
140 | } | 147 | } |
141 | 148 | ||
149 | @errcounts = sort { $b->[3] <=> $a->[3] } @errcounts; | ||
150 | |||
151 | for my $i (0 .. $#errcounts) { | ||
152 | printf("%6d %-20s %6d %10s\n", $errcounts[$i][0], | ||
153 | $errcounts[$i][1], $errcounts[$i][2], $errcounts[$i][3]); | ||
154 | } | ||
155 | |||
142 | print_unhandled(); | 156 | print_unhandled(); |
143 | } | 157 | } |
144 | 158 | ||