2 # (c) 2009, Tom Zanussi <tzanussi@gmail.com>
3 # Licensed under the terms of the GNU GPL License version 2
5 # Displays workqueue stats
9 # perf record -c 1 -f -a -R -e workqueue:workqueue_creation -e
10 # workqueue:workqueue_destruction -e workqueue:workqueue_execution
11 # -e workqueue:workqueue_insertion
13 # perf trace -p -s tools/perf/scripts/perl/workqueue-stats.pl
19 use lib
"$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib";
20 use lib
"./Perf-Trace-Util/lib";
21 use Perf
::Trace
::Core
;
22 use Perf
::Trace
::Util
;
26 sub workqueue
::workqueue_destruction
28 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
29 $common_pid, $common_comm,
30 $thread_comm, $thread_pid) = @_;
32 $cpus[$common_cpu]{$thread_pid}{destroyed
}++;
33 $cpus[$common_cpu]{$thread_pid}{comm
} = $thread_comm;
36 sub workqueue
::workqueue_creation
38 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
39 $common_pid, $common_comm,
40 $thread_comm, $thread_pid, $cpu) = @_;
42 $cpus[$common_cpu]{$thread_pid}{created
}++;
43 $cpus[$common_cpu]{$thread_pid}{comm
} = $thread_comm;
46 sub workqueue
::workqueue_execution
48 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
49 $common_pid, $common_comm,
50 $thread_comm, $thread_pid, $func) = @_;
52 $cpus[$common_cpu]{$thread_pid}{executed
}++;
53 $cpus[$common_cpu]{$thread_pid}{comm
} = $thread_comm;
56 sub workqueue
::workqueue_insertion
58 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
59 $common_pid, $common_comm,
60 $thread_comm, $thread_pid, $func) = @_;
62 $cpus[$common_cpu]{$thread_pid}{inserted
}++;
63 $cpus[$common_cpu]{$thread_pid}{comm
} = $thread_comm;
68 print "workqueue work stats:\n\n";
70 printf("%3s %6s %6s\t%-20s\n", "cpu", "ins", "exec", "name");
71 printf("%3s %6s %6s\t%-20s\n", "---", "---", "----", "----");
72 foreach my $pidhash (@cpus) {
73 while ((my $pid, my $wqhash) = each %$pidhash) {
74 my $ins = $$wqhash{'inserted'};
75 my $exe = $$wqhash{'executed'};
76 my $comm = $$wqhash{'comm'};
78 printf("%3u %6u %6u\t%-20s\n", $cpu, $ins, $exe, $comm);
85 print "\nworkqueue lifecycle stats:\n\n";
86 printf("%3s %6s %6s\t%-20s\n", "cpu", "created", "destroyed", "name");
87 printf("%3s %6s %6s\t%-20s\n", "---", "-------", "---------", "----");
88 foreach my $pidhash (@cpus) {
89 while ((my $pid, my $wqhash) = each %$pidhash) {
90 my $created = $$wqhash{'created'};
91 my $destroyed = $$wqhash{'destroyed'};
92 my $comm = $$wqhash{'comm'};
93 if ($created || $destroyed) {
94 printf("%3u %6u %6u\t%-20s\n", $cpu, $created, $destroyed,
108 if ((scalar keys %unhandled) == 0) {
112 print "\nunhandled events:\n\n";
114 printf("%-40s %10s\n", "event", "count");
115 printf("%-40s %10s\n", "----------------------------------------",
118 foreach my $event_name (keys %unhandled) {
119 printf("%-40s %10d\n", $event_name, $unhandled{$event_name});
125 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
126 $common_pid, $common_comm) = @_;
128 $unhandled{$event_name}++;