aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/perf_counter/builtin-top.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-06-05 13:31:01 -0400
committerIngo Molnar <mingo@elte.hu>2009-06-05 14:42:53 -0400
commit2f335a02b3c816e77e7df1d15b12e3bbb8f4c8f0 (patch)
tree2e4bd6040936f5ac8964f8034918c653d36dd53f /Documentation/perf_counter/builtin-top.c
parent1dba15e74aba5a90c1f2557f37e5d09f8a2df643 (diff)
perf top: Fix zero or negative refresh delay
If perf top is executed with a zero value for the refresh rate, we get a division by zero exception while computing samples_per_sec. Also a zero refresh rate is not possible, neither do we want to accept negative values. [ Impact: fix division by zero in perf top ] Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <1244223061-5399-1-git-send-email-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'Documentation/perf_counter/builtin-top.c')
-rw-r--r--Documentation/perf_counter/builtin-top.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Documentation/perf_counter/builtin-top.c b/Documentation/perf_counter/builtin-top.c
index ff7e13c4647c..b2f480b5a134 100644
--- a/Documentation/perf_counter/builtin-top.c
+++ b/Documentation/perf_counter/builtin-top.c
@@ -693,6 +693,9 @@ int cmd_top(int argc, const char **argv, const char *prefix)
693 event_id[0] = 0; 693 event_id[0] = 0;
694 } 694 }
695 695
696 if (delay_secs < 1)
697 delay_secs = 1;
698
696 for (counter = 0; counter < nr_counters; counter++) { 699 for (counter = 0; counter < nr_counters; counter++) {
697 if (event_count[counter]) 700 if (event_count[counter])
698 continue; 701 continue;