From: Peter Zijlstra <peterz@infradead.org>
To: Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] perf_counter: fix possible /0 bug in swcounters
Date: Fri, 28 Aug 2009 17:10:47 +0200 [thread overview]
Message-ID: <1251472247.17617.74.camel@laptop> (raw)
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);
next reply other threads:[~2009-08-28 15:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-28 15:10 Peter Zijlstra [this message]
2009-08-29 11:25 ` [tip:perfcounters/urgent] perf_counter: Fix /0 bug in swcounters tip-bot for Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1251472247.17617.74.camel@laptop \
--to=peterz@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox