Skip to contentSkip to conversation

perfcounter: fix zero or negative refresh delay

PATCH In review Frederic Weisbecker 1 participant 2 messages Jun 5, 2009 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perfcounter: 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 <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Corey Ashford <[email protected]>
Cc Marcelo Tosatti <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
---
 Documentation/perf_counter/builtin-top.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Documentation/perf_counter/builtin-top.c +3 -0
index ff7e13c..b2f480b 100644
@@ -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;
Signature · 1 line
1.6.2.3
#1 lore raw

[tip:perfcounters/core] perf top: Fix zero or negative refresh delay

Commit-ID:  2f335a02b3c816e77e7df1d15b12e3bbb8f4c8f0
Gitweb:     http://git.kernel.org/tip/2f335a02b3c816e77e7df1d15b12e3bbb8f4c8f0
Author:     Frederic Weisbecker <[email protected]>
AuthorDate: Fri, 5 Jun 2009 19:31:01 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 5 Jun 2009 20:42:53 +0200

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 <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: Marcelo Tosatti <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>

---
 Documentation/perf_counter/builtin-top.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Documentation/perf_counter/builtin-top.c +3 -0
index ff7e13c..b2f480b 100644
@@ -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;