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

perf/trace/scripting: wakeup-latency script cleanup

Some minor fixes for the wakeup-latency script:

- Fix nuisance 'use of uninitialized value' warnings

- Avoid divide-by-zero error

Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
LKML-Reference: <1273466820-9330-5-git-send-email-tzanussi@gmail.com>
Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Tom Zanussi and committed by
Arnaldo Carvalho de Melo
e366728d e88a4bfb

+8 -4
+8 -4
tools/perf/scripts/perl/wakeup-latency.pl
··· 22 22 23 23 my $max_wakeup_latency; 24 24 my $min_wakeup_latency; 25 - my $total_wakeup_latency; 26 - my $total_wakeups; 25 + my $total_wakeup_latency = 0; 26 + my $total_wakeups = 0; 27 27 28 28 sub sched::sched_switch 29 29 { ··· 67 67 { 68 68 printf("wakeup_latency stats:\n\n"); 69 69 print "total_wakeups: $total_wakeups\n"; 70 - printf("avg_wakeup_latency (ns): %u\n", 71 - avg($total_wakeup_latency, $total_wakeups)); 70 + if ($total_wakeups) { 71 + printf("avg_wakeup_latency (ns): %u\n", 72 + avg($total_wakeup_latency, $total_wakeups)); 73 + } else { 74 + printf("avg_wakeup_latency (ns): N/A\n"); 75 + } 72 76 printf("min_wakeup_latency (ns): %u\n", $min_wakeup_latency); 73 77 printf("max_wakeup_latency (ns): %u\n", $max_wakeup_latency); 74 78