diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-05-23 12:28:57 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-23 13:37:46 -0400 |
commit | 682076ae1de0aba9c2da509f7b19dc03e30a6e1f (patch) | |
tree | 63e48b23f8ef4e16b79c9b767def13e7795eb440 /kernel/perf_counter.c | |
parent | fccc714b3148ab9741fafc1e90c3876d50df6093 (diff) |
perf_counter: Sanitize context locking
Ensure we're consistent with the context locks.
context->mutex
context->lock
list_{add,del}_counter();
so that either lock is sufficient to stabilize the context.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: John Kacur <jkacur@redhat.com>
LKML-Reference: <20090523163012.618790733@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/perf_counter.c')
-rw-r--r-- | kernel/perf_counter.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index 679c3b5bb7d4..d162d2f0b270 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c | |||
@@ -597,6 +597,8 @@ static void add_counter_to_ctx(struct perf_counter *counter, | |||
597 | 597 | ||
598 | /* | 598 | /* |
599 | * Cross CPU call to install and enable a performance counter | 599 | * Cross CPU call to install and enable a performance counter |
600 | * | ||
601 | * Must be called with ctx->mutex held | ||
600 | */ | 602 | */ |
601 | static void __perf_install_in_context(void *info) | 603 | static void __perf_install_in_context(void *info) |
602 | { | 604 | { |
@@ -1496,13 +1498,13 @@ static void perf_counter_for_each_sibling(struct perf_counter *counter, | |||
1496 | struct perf_counter_context *ctx = counter->ctx; | 1498 | struct perf_counter_context *ctx = counter->ctx; |
1497 | struct perf_counter *sibling; | 1499 | struct perf_counter *sibling; |
1498 | 1500 | ||
1499 | spin_lock_irq(&ctx->lock); | 1501 | mutex_lock(&ctx->mutex); |
1500 | counter = counter->group_leader; | 1502 | counter = counter->group_leader; |
1501 | 1503 | ||
1502 | func(counter); | 1504 | func(counter); |
1503 | list_for_each_entry(sibling, &counter->sibling_list, list_entry) | 1505 | list_for_each_entry(sibling, &counter->sibling_list, list_entry) |
1504 | func(sibling); | 1506 | func(sibling); |
1505 | spin_unlock_irq(&ctx->lock); | 1507 | mutex_unlock(&ctx->mutex); |
1506 | } | 1508 | } |
1507 | 1509 | ||
1508 | static void perf_counter_for_each_child(struct perf_counter *counter, | 1510 | static void perf_counter_for_each_child(struct perf_counter *counter, |
@@ -3414,7 +3416,10 @@ __perf_counter_exit_task(struct task_struct *child, | |||
3414 | struct perf_counter *parent_counter; | 3416 | struct perf_counter *parent_counter; |
3415 | 3417 | ||
3416 | update_counter_times(child_counter); | 3418 | update_counter_times(child_counter); |
3419 | |||
3420 | spin_lock_irq(&child_ctx->lock); | ||
3417 | list_del_counter(child_counter, child_ctx); | 3421 | list_del_counter(child_counter, child_ctx); |
3422 | spin_unlock_irq(&child_ctx->lock); | ||
3418 | 3423 | ||
3419 | parent_counter = child_counter->parent; | 3424 | parent_counter = child_counter->parent; |
3420 | /* | 3425 | /* |