diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-04-06 05:44:59 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-07 04:48:54 -0400 |
commit | a2e87d06ddbe6e6fdb8d6d2e5e985efe4efb07dd (patch) | |
tree | af0fdeb24c4e957d4e87a50ba358e5fdba6f7600 /include/linux/perf_counter.h | |
parent | 92f22a3865abe87eea2609a6f8e5be5123f7ce4f (diff) |
perf_counter: update mmap() counter read, take 2
Update the userspace read method.
Paul noted that:
- userspace cannot observe ->lock & 1 on the same cpu.
- we need a barrier() between reading ->lock and ->index
to ensure we read them in that prticular order.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
LKML-Reference: <20090406094517.368446033@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/perf_counter.h')
-rw-r--r-- | include/linux/perf_counter.h | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h index f2b914de3f0c..e22ab47a2f41 100644 --- a/include/linux/perf_counter.h +++ b/include/linux/perf_counter.h | |||
@@ -170,22 +170,18 @@ struct perf_counter_mmap_page { | |||
170 | * u32 seq; | 170 | * u32 seq; |
171 | * s64 count; | 171 | * s64 count; |
172 | * | 172 | * |
173 | * again: | 173 | * do { |
174 | * seq = pc->lock; | 174 | * seq = pc->lock; |
175 | * if (unlikely(seq & 1)) { | ||
176 | * cpu_relax(); | ||
177 | * goto again; | ||
178 | * } | ||
179 | * | 175 | * |
180 | * if (pc->index) { | 176 | * barrier() |
181 | * count = pmc_read(pc->index - 1); | 177 | * if (pc->index) { |
182 | * count += pc->offset; | 178 | * count = pmc_read(pc->index - 1); |
183 | * } else | 179 | * count += pc->offset; |
184 | * goto regular_read; | 180 | * } else |
181 | * goto regular_read; | ||
185 | * | 182 | * |
186 | * barrier(); | 183 | * barrier(); |
187 | * if (pc->lock != seq) | 184 | * } while (pc->lock != seq); |
188 | * goto again; | ||
189 | * | 185 | * |
190 | * NOTE: for obvious reason this only works on self-monitoring | 186 | * NOTE: for obvious reason this only works on self-monitoring |
191 | * processes. | 187 | * processes. |