Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf scripting perl: Add common_callchain to fix argument order

Since common_callchain has been added to the argument array, we need to
reflect it in perl-based scripts, because otherwise the following args
would be shifted and thus incorrect. E.g. rw-by-pid and calculation of
read and written bytes:

Before:

read counts by pid:
pid comm # reads bytes_requested bytes_read
------ -------------------- ----------- ---------- ----------
19301 dd 4 424510450039736 0

After:

read counts by pid:
pid comm # reads bytes_requested bytes_read
------ -------------------- ----------- ---------- ----------
19301 dd 4 9536 4341

Committer testing:

To see before after first do:

# perf script record rw-by-pid
^C

Now you'll have a perf.data file to report on, then do before and after
using:

# perf script report rw-by-pid

Anbd notice the bytes_request/bytes_read, as above.

Signed-off-by: Michael Petlan <mpetlan@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Benjamin Salon <bsalon@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
LPU-Reference: 20200311132836.12693-1-mpetlan@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Michael Petlan and committed by
Arnaldo Carvalho de Melo
67439d55 ec2eab9d

+20 -20
+3 -3
tools/perf/scripts/perl/check-perf-trace.pl
··· 28 28 sub irq::softirq_entry 29 29 { 30 30 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 31 - $common_pid, $common_comm, 31 + $common_pid, $common_comm, $common_callchain, 32 32 $vec) = @_; 33 33 34 34 print_header($event_name, $common_cpu, $common_secs, $common_nsecs, ··· 43 43 sub kmem::kmalloc 44 44 { 45 45 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 46 - $common_pid, $common_comm, 46 + $common_pid, $common_comm, $common_callchain, 47 47 $call_site, $ptr, $bytes_req, $bytes_alloc, 48 48 $gfp_flags) = @_; 49 49 ··· 92 92 sub trace_unhandled 93 93 { 94 94 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 95 - $common_pid, $common_comm) = @_; 95 + $common_pid, $common_comm, $common_callchain) = @_; 96 96 97 97 $unhandled{$event_name}++; 98 98 }
+1 -1
tools/perf/scripts/perl/failed-syscalls.pl
··· 18 18 sub raw_syscalls::sys_exit 19 19 { 20 20 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 21 - $common_pid, $common_comm, 21 + $common_pid, $common_comm, $common_callchain, 22 22 $id, $ret) = @_; 23 23 24 24 if ($ret < 0) {
+3 -3
tools/perf/scripts/perl/rw-by-file.pl
··· 28 28 sub syscalls::sys_enter_read 29 29 { 30 30 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 31 - $common_pid, $common_comm, $nr, $fd, $buf, $count) = @_; 31 + $common_pid, $common_comm, $common_callchain, $nr, $fd, $buf, $count) = @_; 32 32 33 33 if ($common_comm eq $for_comm) { 34 34 $reads{$fd}{bytes_requested} += $count; ··· 39 39 sub syscalls::sys_enter_write 40 40 { 41 41 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 42 - $common_pid, $common_comm, $nr, $fd, $buf, $count) = @_; 42 + $common_pid, $common_comm, $common_callchain, $nr, $fd, $buf, $count) = @_; 43 43 44 44 if ($common_comm eq $for_comm) { 45 45 $writes{$fd}{bytes_written} += $count; ··· 98 98 sub trace_unhandled 99 99 { 100 100 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 101 - $common_pid, $common_comm) = @_; 101 + $common_pid, $common_comm, $common_callchain) = @_; 102 102 103 103 $unhandled{$event_name}++; 104 104 }
+5 -5
tools/perf/scripts/perl/rw-by-pid.pl
··· 24 24 sub syscalls::sys_exit_read 25 25 { 26 26 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 27 - $common_pid, $common_comm, 27 + $common_pid, $common_comm, $common_callchain, 28 28 $nr, $ret) = @_; 29 29 30 30 if ($ret > 0) { ··· 40 40 sub syscalls::sys_enter_read 41 41 { 42 42 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 43 - $common_pid, $common_comm, 43 + $common_pid, $common_comm, $common_callchain, 44 44 $nr, $fd, $buf, $count) = @_; 45 45 46 46 $reads{$common_pid}{bytes_requested} += $count; ··· 51 51 sub syscalls::sys_exit_write 52 52 { 53 53 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 54 - $common_pid, $common_comm, 54 + $common_pid, $common_comm, $common_callchain, 55 55 $nr, $ret) = @_; 56 56 57 57 if ($ret <= 0) { ··· 62 62 sub syscalls::sys_enter_write 63 63 { 64 64 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 65 - $common_pid, $common_comm, 65 + $common_pid, $common_comm, $common_callchain, 66 66 $nr, $fd, $buf, $count) = @_; 67 67 68 68 $writes{$common_pid}{bytes_written} += $count; ··· 178 178 sub trace_unhandled 179 179 { 180 180 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 181 - $common_pid, $common_comm) = @_; 181 + $common_pid, $common_comm, $common_callchain) = @_; 182 182 183 183 $unhandled{$event_name}++; 184 184 }
+5 -5
tools/perf/scripts/perl/rwtop.pl
··· 35 35 sub syscalls::sys_exit_read 36 36 { 37 37 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 38 - $common_pid, $common_comm, 38 + $common_pid, $common_comm, $common_callchain, 39 39 $nr, $ret) = @_; 40 40 41 41 print_check(); ··· 53 53 sub syscalls::sys_enter_read 54 54 { 55 55 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 56 - $common_pid, $common_comm, 56 + $common_pid, $common_comm, $common_callchain, 57 57 $nr, $fd, $buf, $count) = @_; 58 58 59 59 print_check(); ··· 66 66 sub syscalls::sys_exit_write 67 67 { 68 68 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 69 - $common_pid, $common_comm, 69 + $common_pid, $common_comm, $common_callchain, 70 70 $nr, $ret) = @_; 71 71 72 72 print_check(); ··· 79 79 sub syscalls::sys_enter_write 80 80 { 81 81 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 82 - $common_pid, $common_comm, 82 + $common_pid, $common_comm, $common_callchain, 83 83 $nr, $fd, $buf, $count) = @_; 84 84 85 85 print_check(); ··· 197 197 sub trace_unhandled 198 198 { 199 199 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 200 - $common_pid, $common_comm) = @_; 200 + $common_pid, $common_comm, $common_callchain) = @_; 201 201 202 202 $unhandled{$event_name}++; 203 203 }
+3 -3
tools/perf/scripts/perl/wakeup-latency.pl
··· 28 28 sub sched::sched_switch 29 29 { 30 30 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 31 - $common_pid, $common_comm, 31 + $common_pid, $common_comm, $common_callchain, 32 32 $prev_comm, $prev_pid, $prev_prio, $prev_state, $next_comm, $next_pid, 33 33 $next_prio) = @_; 34 34 ··· 51 51 sub sched::sched_wakeup 52 52 { 53 53 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 54 - $common_pid, $common_comm, 54 + $common_pid, $common_comm, $common_callchain, 55 55 $comm, $pid, $prio, $success, $target_cpu) = @_; 56 56 57 57 $last_wakeup{$target_cpu}{ts} = nsecs($common_secs, $common_nsecs); ··· 101 101 sub trace_unhandled 102 102 { 103 103 my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 104 - $common_pid, $common_comm) = @_; 104 + $common_pid, $common_comm, $common_callchain) = @_; 105 105 106 106 $unhandled{$event_name}++; 107 107 }