diff options
author | Paul Mackerras <paulus@samba.org> | 2009-06-04 22:36:28 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-06-05 02:22:26 -0400 |
commit | 6dc5f2a41759987e35e757ef00192e7b424563bb (patch) | |
tree | b7dddd415cd2d4dcf4e060a8fc769903d2a57a01 | |
parent | 76a0f40fd6eff1bce3b91925cea7587b3399fe80 (diff) |
perf_counter: Fix lockup with interrupting counters
Commit 8e3747c1 ("perf_counter: Change data head from u32 to u64")
changed the type of 'head' in struct perf_mmap_data from atomic_t
to atomic_long_t, but missed converting one use of atomic_read on
it to atomic_long_read. The effect of using atomic_read rather than
atomic_long_read on powerpc (and other big-endian architectures) is
that we get the high half of the 64-bit quantity, resulting in the
cmpxchg retry loop in perf_output_begin spinning forever as soon as
data->head becomes non-zero. On little-endian architectures such as
x86 we would get the low half, resulting in a lockup once data->head
becomes greater than 4G.
This fixes it by using atomic_long_read rather than atomic_read.
[ Impact: fix perfcounter lockup on PowerPC / big-endian systems ]
Signed-off-by: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <18984.33964.21541.743096@cargo.ozlabs.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/perf_counter.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index 195712e20d07..a5d3e2aedd2f 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c | |||
@@ -2234,7 +2234,7 @@ static int perf_output_begin(struct perf_output_handle *handle, | |||
2234 | perf_output_lock(handle); | 2234 | perf_output_lock(handle); |
2235 | 2235 | ||
2236 | do { | 2236 | do { |
2237 | offset = head = atomic_read(&data->head); | 2237 | offset = head = atomic_long_read(&data->head); |
2238 | head += size; | 2238 | head += size; |
2239 | } while (atomic_long_cmpxchg(&data->head, offset, head) != offset); | 2239 | } while (atomic_long_cmpxchg(&data->head, offset, head) != offset); |
2240 | 2240 | ||