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/perl/wakeup-latency.pl | |
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/perl/wakeup-latency.pl')
-rw-r--r-- | tools/perf/scripts/perl/wakeup-latency.pl | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/tools/perf/scripts/perl/wakeup-latency.pl b/tools/perf/scripts/perl/wakeup-latency.pl new file mode 100644 index 000000000000..ed58ef284e23 --- /dev/null +++ b/tools/perf/scripts/perl/wakeup-latency.pl | |||
@@ -0,0 +1,103 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | # (c) 2009, Tom Zanussi <tzanussi@gmail.com> | ||
3 | # Licensed under the terms of the GNU GPL License version 2 | ||
4 | |||
5 | # Display avg/min/max wakeup latency | ||
6 | |||
7 | # The common_* event handler fields are the most useful fields common to | ||
8 | # all events. They don't necessarily correspond to the 'common_*' fields | ||
9 | # in the status files. Those fields not available as handler params can | ||
10 | # be retrieved via script functions of the form get_common_*(). | ||
11 | |||
12 | use 5.010000; | ||
13 | use strict; | ||
14 | use warnings; | ||
15 | |||
16 | use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib"; | ||
17 | use lib "./Perf-Trace-Util/lib"; | ||
18 | use Perf::Trace::Core; | ||
19 | use Perf::Trace::Util; | ||
20 | |||
21 | my %last_wakeup; | ||
22 | |||
23 | my $max_wakeup_latency; | ||
24 | my $min_wakeup_latency; | ||
25 | my $total_wakeup_latency; | ||
26 | my $total_wakeups; | ||
27 | |||
28 | sub sched::sched_switch | ||
29 | { | ||
30 | my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, | ||
31 | $common_pid, $common_comm, | ||
32 | $prev_comm, $prev_pid, $prev_prio, $prev_state, $next_comm, $next_pid, | ||
33 | $next_prio) = @_; | ||
34 | |||
35 | my $wakeup_ts = $last_wakeup{$common_cpu}{ts}; | ||
36 | if ($wakeup_ts) { | ||
37 | my $switch_ts = nsecs($common_secs, $common_nsecs); | ||
38 | my $wakeup_latency = $switch_ts - $wakeup_ts; | ||
39 | if ($wakeup_latency > $max_wakeup_latency) { | ||
40 | $max_wakeup_latency = $wakeup_latency; | ||
41 | } | ||
42 | if ($wakeup_latency < $min_wakeup_latency) { | ||
43 | $min_wakeup_latency = $wakeup_latency; | ||
44 | } | ||
45 | $total_wakeup_latency += $wakeup_latency; | ||
46 | $total_wakeups++; | ||
47 | } | ||
48 | $last_wakeup{$common_cpu}{ts} = 0; | ||
49 | } | ||
50 | |||
51 | sub sched::sched_wakeup | ||
52 | { | ||
53 | my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, | ||
54 | $common_pid, $common_comm, | ||
55 | $comm, $pid, $prio, $success, $target_cpu) = @_; | ||
56 | |||
57 | $last_wakeup{$target_cpu}{ts} = nsecs($common_secs, $common_nsecs); | ||
58 | } | ||
59 | |||
60 | sub trace_begin | ||
61 | { | ||
62 | $min_wakeup_latency = 1000000000; | ||
63 | $max_wakeup_latency = 0; | ||
64 | } | ||
65 | |||
66 | sub trace_end | ||
67 | { | ||
68 | printf("wakeup_latency stats:\n\n"); | ||
69 | print "total_wakeups: $total_wakeups\n"; | ||
70 | printf("avg_wakeup_latency (ns): %u\n", | ||
71 | avg($total_wakeup_latency, $total_wakeups)); | ||
72 | printf("min_wakeup_latency (ns): %u\n", $min_wakeup_latency); | ||
73 | printf("max_wakeup_latency (ns): %u\n", $max_wakeup_latency); | ||
74 | |||
75 | print_unhandled(); | ||
76 | } | ||
77 | |||
78 | my %unhandled; | ||
79 | |||
80 | sub print_unhandled | ||
81 | { | ||
82 | if ((scalar keys %unhandled) == 0) { | ||
83 | return; | ||
84 | } | ||
85 | |||
86 | print "\nunhandled events:\n\n"; | ||
87 | |||
88 | printf("%-40s %10s\n", "event", "count"); | ||
89 | printf("%-40s %10s\n", "----------------------------------------", | ||
90 | "-----------"); | ||
91 | |||
92 | foreach my $event_name (keys %unhandled) { | ||
93 | printf("%-40s %10d\n", $event_name, $unhandled{$event_name}); | ||
94 | } | ||
95 | } | ||
96 | |||
97 | sub trace_unhandled | ||
98 | { | ||
99 | my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, | ||
100 | $common_pid, $common_comm) = @_; | ||
101 | |||
102 | $unhandled{$event_name}++; | ||
103 | } | ||