Skip to content

Commit

Permalink
perf_counter: add comment to barrier
Browse files Browse the repository at this point in the history
We need to ensure the enabled=0 write happens before we
start disabling the actual counters, so that a pcm_amd_enable()
will not enable one underneath us.

I think the race is impossible anyway, we always balance the
ops within any one context and perform enable() with IRQs disabled.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Apr 6, 2009
1 parent 7556423 commit 60b3df9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/x86/kernel/cpu/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ static u64 pmc_amd_save_disable_all(void)

enabled = cpuc->enabled;
cpuc->enabled = 0;
/*
* ensure we write the disable before we start disabling the
* counters proper, so that pcm_amd_enable() does the right thing.
*/
barrier();

for (idx = 0; idx < nr_counters_generic; idx++) {
Expand Down

0 comments on commit 60b3df9

Please sign in to comment.