~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/scripts/perl/rw-by-file.pl

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/perf/scripts/perl/rw-by-file.pl (Architecture alpha) and /tools/perf/scripts/perl/rw-by-file.pl (Architecture m68k)


  1 #!/usr/bin/perl -w                                  1 #!/usr/bin/perl -w
  2 # SPDX-License-Identifier: GPL-2.0-only             2 # SPDX-License-Identifier: GPL-2.0-only
  3 # (c) 2009, Tom Zanussi <tzanussi@gmail.com>         3 # (c) 2009, Tom Zanussi <tzanussi@gmail.com>
  4                                                     4 
  5 # Display r/w activity for files read/written       5 # Display r/w activity for files read/written to for a given program
  6                                                     6 
  7 # The common_* event handler fields are the mo      7 # The common_* event handler fields are the most useful fields common to
  8 # all events.  They don't necessarily correspo      8 # all events.  They don't necessarily correspond to the 'common_*' fields
  9 # in the status files.  Those fields not avail      9 # in the status files.  Those fields not available as handler params can
 10 # be retrieved via script functions of the for     10 # be retrieved via script functions of the form get_common_*().
 11                                                    11 
 12 use 5.010000;                                      12 use 5.010000;
 13 use strict;                                        13 use strict;
 14 use warnings;                                      14 use warnings;
 15                                                    15 
 16 use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/P     16 use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib";
 17 use lib "./Perf-Trace-Util/lib";                   17 use lib "./Perf-Trace-Util/lib";
 18 use Perf::Trace::Core;                             18 use Perf::Trace::Core;
 19 use Perf::Trace::Util;                             19 use Perf::Trace::Util;
 20                                                    20 
 21 my $usage = "perf script -s rw-by-file.pl <com     21 my $usage = "perf script -s rw-by-file.pl <comm>\n";
 22                                                    22 
 23 my $for_comm = shift or die $usage;                23 my $for_comm = shift or die $usage;
 24                                                    24 
 25 my %reads;                                         25 my %reads;
 26 my %writes;                                        26 my %writes;
 27                                                    27 
 28 sub syscalls::sys_enter_read                       28 sub syscalls::sys_enter_read
 29 {                                                  29 {
 30     my ($event_name, $context, $common_cpu, $c     30     my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
 31         $common_pid, $common_comm, $common_cal     31         $common_pid, $common_comm, $common_callchain, $nr, $fd, $buf, $count) = @_;
 32                                                    32 
 33     if ($common_comm eq $for_comm) {               33     if ($common_comm eq $for_comm) {
 34         $reads{$fd}{bytes_requested} += $count     34         $reads{$fd}{bytes_requested} += $count;
 35         $reads{$fd}{total_reads}++;                35         $reads{$fd}{total_reads}++;
 36     }                                              36     }
 37 }                                                  37 }
 38                                                    38 
 39 sub syscalls::sys_enter_write                      39 sub syscalls::sys_enter_write
 40 {                                                  40 {
 41     my ($event_name, $context, $common_cpu, $c     41     my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
 42         $common_pid, $common_comm, $common_cal     42         $common_pid, $common_comm, $common_callchain, $nr, $fd, $buf, $count) = @_;
 43                                                    43 
 44     if ($common_comm eq $for_comm) {               44     if ($common_comm eq $for_comm) {
 45         $writes{$fd}{bytes_written} += $count;     45         $writes{$fd}{bytes_written} += $count;
 46         $writes{$fd}{total_writes}++;              46         $writes{$fd}{total_writes}++;
 47     }                                              47     }
 48 }                                                  48 }
 49                                                    49 
 50 sub trace_end                                      50 sub trace_end
 51 {                                                  51 {
 52     printf("file read counts for $for_comm:\n\     52     printf("file read counts for $for_comm:\n\n");
 53                                                    53 
 54     printf("%6s  %10s  %10s\n", "fd", "# reads     54     printf("%6s  %10s  %10s\n", "fd", "# reads", "bytes_requested");
 55     printf("%6s  %10s  %10s\n", "------", "---     55     printf("%6s  %10s  %10s\n", "------", "----------", "-----------");
 56                                                    56 
 57     foreach my $fd (sort {$reads{$b}{bytes_req     57     foreach my $fd (sort {$reads{$b}{bytes_requested} <=>
 58                               $reads{$a}{bytes     58                               $reads{$a}{bytes_requested}} keys %reads) {
 59         my $total_reads = $reads{$fd}{total_re     59         my $total_reads = $reads{$fd}{total_reads};
 60         my $bytes_requested = $reads{$fd}{byte     60         my $bytes_requested = $reads{$fd}{bytes_requested};
 61         printf("%6u  %10u  %10u\n", $fd, $tota     61         printf("%6u  %10u  %10u\n", $fd, $total_reads, $bytes_requested);
 62     }                                              62     }
 63                                                    63 
 64     printf("\nfile write counts for $for_comm:     64     printf("\nfile write counts for $for_comm:\n\n");
 65                                                    65 
 66     printf("%6s  %10s  %10s\n", "fd", "# write     66     printf("%6s  %10s  %10s\n", "fd", "# writes", "bytes_written");
 67     printf("%6s  %10s  %10s\n", "------", "---     67     printf("%6s  %10s  %10s\n", "------", "----------", "-----------");
 68                                                    68 
 69     foreach my $fd (sort {$writes{$b}{bytes_wr     69     foreach my $fd (sort {$writes{$b}{bytes_written} <=>
 70                               $writes{$a}{byte     70                               $writes{$a}{bytes_written}} keys %writes) {
 71         my $total_writes = $writes{$fd}{total_     71         my $total_writes = $writes{$fd}{total_writes};
 72         my $bytes_written = $writes{$fd}{bytes     72         my $bytes_written = $writes{$fd}{bytes_written};
 73         printf("%6u  %10u  %10u\n", $fd, $tota     73         printf("%6u  %10u  %10u\n", $fd, $total_writes, $bytes_written);
 74     }                                              74     }
 75                                                    75 
 76     print_unhandled();                             76     print_unhandled();
 77 }                                                  77 }
 78                                                    78 
 79 my %unhandled;                                     79 my %unhandled;
 80                                                    80 
 81 sub print_unhandled                                81 sub print_unhandled
 82 {                                                  82 {
 83     if ((scalar keys %unhandled) == 0) {           83     if ((scalar keys %unhandled) == 0) {
 84         return;                                    84         return;
 85     }                                              85     }
 86                                                    86 
 87     print "\nunhandled events:\n\n";               87     print "\nunhandled events:\n\n";
 88                                                    88 
 89     printf("%-40s  %10s\n", "event", "count");     89     printf("%-40s  %10s\n", "event", "count");
 90     printf("%-40s  %10s\n", "-----------------     90     printf("%-40s  %10s\n", "----------------------------------------",
 91            "-----------");                         91            "-----------");
 92                                                    92 
 93     foreach my $event_name (keys %unhandled) {     93     foreach my $event_name (keys %unhandled) {
 94         printf("%-40s  %10d\n", $event_name, $     94         printf("%-40s  %10d\n", $event_name, $unhandled{$event_name});
 95     }                                              95     }
 96 }                                                  96 }
 97                                                    97 
 98 sub trace_unhandled                                98 sub trace_unhandled
 99 {                                                  99 {
100     my ($event_name, $context, $common_cpu, $c    100     my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
101         $common_pid, $common_comm, $common_cal    101         $common_pid, $common_comm, $common_callchain) = @_;
102                                                   102 
103     $unhandled{$event_name}++;                    103     $unhandled{$event_name}++;
104 }                                                 104 }
105                                                   105 
106                                                   106 
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php