Skip to content

Commit

Permalink
perf top: Fix zero or negative refresh delay
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed Jun 5, 2009
1 parent 1dba15e commit 2f335a0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Documentation/perf_counter/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,9 @@ int cmd_top(int argc, const char **argv, const char *prefix)
event_id[0] = 0;
}

if (delay_secs < 1)
delay_secs = 1;

for (counter = 0; counter < nr_counters; counter++) {
if (event_count[counter])
continue;
Expand Down

0 comments on commit 2f335a0

Please sign in to comment.