Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 191337
b: refs/heads/master
c: e88a4bf
h: refs/heads/master
i:
  191335: 39e80bf
v: v3
  • Loading branch information
Tom Zanussi authored and Arnaldo Carvalho de Melo committed May 10, 2010
1 parent a039f77 commit 69c0db3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6922c3d772711239e75ddaea760e6b0535e7e7a6
refs/heads/master: e88a4bfbcda440b1c6b9d5a31a554a6ad9686182
48 changes: 35 additions & 13 deletions trunk/tools/perf/scripts/perl/rwtop.pl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
my $default_interval = 3;
my $nlines = 20;
my $print_thread;
my $print_pending = 0;

my %reads;
my %writes;
Expand All @@ -36,6 +37,8 @@ sub syscalls::sys_exit_read
$common_pid, $common_comm,
$nr, $ret) = @_;

print_check();

if ($ret > 0) {
$reads{$common_pid}{bytes_read} += $ret;
} else {
Expand All @@ -52,6 +55,8 @@ sub syscalls::sys_enter_read
$common_pid, $common_comm,
$nr, $fd, $buf, $count) = @_;

print_check();

$reads{$common_pid}{bytes_requested} += $count;
$reads{$common_pid}{total_reads}++;
$reads{$common_pid}{comm} = $common_comm;
Expand All @@ -63,6 +68,8 @@ sub syscalls::sys_exit_write
$common_pid, $common_comm,
$nr, $ret) = @_;

print_check();

if ($ret <= 0) {
$writes{$common_pid}{errors}{$ret}++;
}
Expand All @@ -74,14 +81,16 @@ sub syscalls::sys_enter_write
$common_pid, $common_comm,
$nr, $fd, $buf, $count) = @_;

print_check();

$writes{$common_pid}{bytes_written} += $count;
$writes{$common_pid}{total_writes}++;
$writes{$common_pid}{comm} = $common_comm;
}

sub trace_begin
{
$SIG{ALRM} = \&print_totals;
$SIG{ALRM} = \&set_print_pending;
alarm 1;
}

Expand All @@ -91,6 +100,20 @@ sub trace_end
print_totals();
}

sub print_check()
{
if ($print_pending == 1) {
$print_pending = 0;
print_totals();
}
}

sub set_print_pending()
{
$print_pending = 1;
alarm $interval;
}

sub print_totals
{
my $count;
Expand All @@ -106,12 +129,12 @@ sub print_totals
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 @@ -130,11 +153,11 @@ sub print_totals
printf("%6s %-20s %10s %13s\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 %13s\n", $pid, $comm,
$total_writes, $bytes_written);
Expand All @@ -146,7 +169,6 @@ sub print_totals

%reads = ();
%writes = ();
alarm $interval;
}

my %unhandled;
Expand Down

0 comments on commit 69c0db3

Please sign in to comment.