diff options
| author | Tom Zanussi <tzanussi@gmail.com> | 2009-11-25 02:15:49 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2009-11-28 04:04:26 -0500 |
| commit | bcefe12eff5dca6fdfa94ed85e5bee66380d5cd9 (patch) | |
| tree | 9a0f39f63d4e542322f4bc58626e1bd1d3d0f3c1 /tools/perf/scripts | |
| parent | 16c632de64a74644a46e7636db26b2cfb530ca13 (diff) | |
perf trace: Add perf trace scripting support modules for Perl
Add Perf-Trace-Util Perl module and some scripts that use it.
Core.pm contains Perl code to define and access flag and
symbolic fields. Util.pm contains general-purpose utility
functions.
Also adds some makefile bits to install them in
libexec/perf-core/scripts/perl (or wherever perfexec_instdir
points).
Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
Cc: fweisbec@gmail.com
Cc: rostedt@goodmis.org
Cc: anton@samba.org
Cc: hch@infradead.org
LKML-Reference: <1259133352-23685-5-git-send-email-tzanussi@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/scripts')
| -rw-r--r-- | tools/perf/scripts/perl/Perf-Trace-Util/Makefile.PL | 12 | ||||
| -rw-r--r-- | tools/perf/scripts/perl/Perf-Trace-Util/README | 35 | ||||
| -rw-r--r-- | tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Core.pm | 157 | ||||
| -rw-r--r-- | tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Util.pm | 88 | ||||
| -rw-r--r-- | tools/perf/scripts/perl/rw-by-file.pl | 105 | ||||
| -rw-r--r-- | tools/perf/scripts/perl/rw-by-pid.pl | 170 | ||||
| -rw-r--r-- | tools/perf/scripts/perl/wakeup-latency.pl | 103 | ||||
| -rw-r--r-- | tools/perf/scripts/perl/workqueue-stats.pl | 129 |
8 files changed, 799 insertions, 0 deletions
diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/Makefile.PL b/tools/perf/scripts/perl/Perf-Trace-Util/Makefile.PL new file mode 100644 index 000000000000..b0de02e6950d --- /dev/null +++ b/tools/perf/scripts/perl/Perf-Trace-Util/Makefile.PL | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | use 5.010000; | ||
| 2 | use ExtUtils::MakeMaker; | ||
| 3 | # See lib/ExtUtils/MakeMaker.pm for details of how to influence | ||
| 4 | # the contents of the Makefile that is written. | ||
| 5 | WriteMakefile( | ||
| 6 | NAME => 'Perf::Trace::Util', | ||
| 7 | VERSION_FROM => 'lib/Perf/Trace/Util.pm', # finds $VERSION | ||
| 8 | PREREQ_PM => {}, # e.g., Module::Name => 1.1 | ||
| 9 | ($] >= 5.005 ? ## Add these new keywords supported since 5.005 | ||
| 10 | (ABSTRACT_FROM => 'lib/Perf/Trace/Util.pm', # retrieve abstract from module | ||
| 11 | AUTHOR => 'Tom Zanussi <tzanussi@gmail.com>') : ()), | ||
| 12 | ); | ||
diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/README b/tools/perf/scripts/perl/Perf-Trace-Util/README new file mode 100644 index 000000000000..0a58378f0836 --- /dev/null +++ b/tools/perf/scripts/perl/Perf-Trace-Util/README | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | Perf-Trace-Util version 0.01 | ||
| 2 | ============================ | ||
| 3 | |||
| 4 | This module contains utility functions for use with perf trace. | ||
| 5 | |||
| 6 | INSTALLATION | ||
| 7 | |||
| 8 | Building perf with perf trace Perl scripting should install this | ||
| 9 | module in the right place. | ||
| 10 | |||
| 11 | You should make sure libperl is installed first e.g. apt-get install | ||
| 12 | libperl-dev. | ||
| 13 | |||
| 14 | DEPENDENCIES | ||
| 15 | |||
| 16 | This module requires these other modules and libraries: | ||
| 17 | |||
| 18 | blah blah blah | ||
| 19 | |||
| 20 | COPYRIGHT AND LICENCE | ||
| 21 | |||
| 22 | Put the correct copyright and licence information here. | ||
| 23 | |||
| 24 | Copyright (C) 2009 by Tom Zanussi <tzanussi@gmail.com> | ||
| 25 | |||
| 26 | This library is free software; you can redistribute it and/or modify | ||
| 27 | it under the same terms as Perl itself, either Perl version 5.10.0 or, | ||
| 28 | at your option, any later version of Perl 5 you may have available. | ||
| 29 | |||
| 30 | Alternatively, this software may be distributed under the terms of the | ||
| 31 | GNU General Public License ("GPL") version 2 as published by the Free | ||
| 32 | Software Foundation. | ||
| 33 | |||
| 34 | |||
| 35 | |||
diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Core.pm b/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Core.pm new file mode 100644 index 000000000000..fd250fb7be16 --- /dev/null +++ b/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Core.pm | |||
| @@ -0,0 +1,157 @@ | |||
| 1 | package Perf::Trace::Core; | ||
| 2 | |||
| 3 | use 5.010000; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | require Exporter; | ||
| 8 | |||
| 9 | our @ISA = qw(Exporter); | ||
| 10 | |||
| 11 | our %EXPORT_TAGS = ( 'all' => [ qw( | ||
| 12 | ) ] ); | ||
| 13 | |||
| 14 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | ||
| 15 | |||
| 16 | our @EXPORT = qw( | ||
| 17 | define_flag_field define_flag_value flag_str dump_flag_fields | ||
| 18 | define_symbolic_field define_symbolic_value symbol_str dump_symbolic_fields | ||
| 19 | ); | ||
| 20 | |||
| 21 | our $VERSION = '0.01'; | ||
| 22 | |||
| 23 | my %flag_fields; | ||
| 24 | my %symbolic_fields; | ||
| 25 | |||
| 26 | sub flag_str | ||
| 27 | { | ||
| 28 | my ($event_name, $field_name, $value) = @_; | ||
| 29 | |||
| 30 | my $string; | ||
| 31 | |||
| 32 | if ($flag_fields{$event_name}{$field_name}) { | ||
| 33 | my $print_delim = 0; | ||
| 34 | foreach my $idx (sort {$a <=> $b} keys %{$flag_fields{$event_name}{$field_name}{"values"}}) { | ||
| 35 | if (!$value && !$idx) { | ||
| 36 | $string .= "$flag_fields{$event_name}{$field_name}{'values'}{$idx}"; | ||
| 37 | last; | ||
| 38 | } | ||
| 39 | if ($idx && ($value & $idx) == $idx) { | ||
| 40 | if ($print_delim && $flag_fields{$event_name}{$field_name}{'delim'}) { | ||
| 41 | $string .= " $flag_fields{$event_name}{$field_name}{'delim'} "; | ||
| 42 | } | ||
| 43 | $string .= "$flag_fields{$event_name}{$field_name}{'values'}{$idx}"; | ||
| 44 | $print_delim = 1; | ||
| 45 | $value &= ~$idx; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | return $string; | ||
| 51 | } | ||
| 52 | |||
| 53 | sub define_flag_field | ||
| 54 | { | ||
| 55 | my ($event_name, $field_name, $delim) = @_; | ||
| 56 | |||
| 57 | $flag_fields{$event_name}{$field_name}{"delim"} = $delim; | ||
| 58 | } | ||
| 59 | |||
| 60 | sub define_flag_value | ||
| 61 | { | ||
| 62 | my ($event_name, $field_name, $value, $field_str) = @_; | ||
| 63 | |||
| 64 | $flag_fields{$event_name}{$field_name}{"values"}{$value} = $field_str; | ||
| 65 | } | ||
| 66 | |||
| 67 | sub dump_flag_fields | ||
| 68 | { | ||
| 69 | for my $event (keys %flag_fields) { | ||
| 70 | print "event $event:\n"; | ||
| 71 | for my $field (keys %{$flag_fields{$event}}) { | ||
| 72 | print " field: $field:\n"; | ||
| 73 | print " delim: $flag_fields{$event}{$field}{'delim'}\n"; | ||
| 74 | foreach my $idx (sort {$a <=> $b} keys %{$flag_fields{$event}{$field}{"values"}}) { | ||
| 75 | print " value $idx: $flag_fields{$event}{$field}{'values'}{$idx}\n"; | ||
| 76 | } | ||
| 77 | } | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | sub symbol_str | ||
| 82 | { | ||
| 83 | my ($event_name, $field_name, $value) = @_; | ||
| 84 | |||
| 85 | if ($symbolic_fields{$event_name}{$field_name}) { | ||
| 86 | foreach my $idx (sort {$a <=> $b} keys %{$symbolic_fields{$event_name}{$field_name}{"values"}}) { | ||
| 87 | if (!$value && !$idx) { | ||
| 88 | return "$symbolic_fields{$event_name}{$field_name}{'values'}{$idx}"; | ||
| 89 | last; | ||
| 90 | } | ||
| 91 | if ($value == $idx) { | ||
| 92 | return "$symbolic_fields{$event_name}{$field_name}{'values'}{$idx}"; | ||
| 93 | } | ||
| 94 | } | ||
| 95 | } | ||
| 96 | |||
| 97 | return undef; | ||
| 98 | } | ||
| 99 | |||
| 100 | sub define_symbolic_field | ||
| 101 | { | ||
| 102 | my ($event_name, $field_name) = @_; | ||
| 103 | |||
| 104 | # nothing to do, really | ||
| 105 | } | ||
| 106 | |||
| 107 | sub define_symbolic_value | ||
| 108 | { | ||
| 109 | my ($event_name, $field_name, $value, $field_str) = @_; | ||
| 110 | |||
| 111 | $symbolic_fields{$event_name}{$field_name}{"values"}{$value} = $field_str; | ||
| 112 | } | ||
