The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] perf_counter: fix possible /0 bug in swcounters
@ 2009-08-28 15:10 Peter Zijlstra
  2009-08-29 11:25 ` [tip:perfcounters/urgent] perf_counter: Fix " tip-bot for Peter Zijlstra
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Zijlstra @ 2009-08-28 15:10 UTC (permalink / raw)
  To: Ingo Molnar, Paul Mackerras; +Cc: lkml

We have a race in the swcounter stuff where we can start counting a
counter that has never been enabled, this leads to a /0 situation.

The below avoids the /0 but doesn't close the race, this would need a
new counter state.

The race is due to perf_swcounter_is_counting() which cannot discern
between disabled due to scheduled out, and disabled for any other
reason.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 kernel/perf_counter.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index 53abcbe..2b90d26 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -4103,6 +4103,7 @@ perf_counter_alloc(struct perf_counter_attr *attr,
 	hwc->sample_period = attr->sample_period;
 	if (attr->freq && attr->sample_freq)
 		hwc->sample_period = 1;
+	hwc->last_period = hwc->sample_period;
 
 	atomic64_set(&hwc->period_left, hwc->sample_period);
 



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-29 11:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-28 15:10 [PATCH] perf_counter: fix possible /0 bug in swcounters Peter Zijlstra
2009-08-29 11:25 ` [tip:perfcounters/urgent] perf_counter: Fix " tip-bot for Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox