mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-19 10:44:14 +08:00
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>
This commit is contained in:
parent
fccc714b31
commit
682076ae1d
@ -597,6 +597,8 @@ static void add_counter_to_ctx(struct perf_counter *counter,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Cross CPU call to install and enable a performance counter
|
* Cross CPU call to install and enable a performance counter
|
||||||
|
*
|
||||||
|
* Must be called with ctx->mutex held
|
||||||
*/
|
*/
|
||||||
static void __perf_install_in_context(void *info)
|
static void __perf_install_in_context(void *info)
|
||||||
{
|
{
|
||||||
@ -1496,13 +1498,13 @@ static void perf_counter_for_each_sibling(struct perf_counter *counter,
|
|||||||
struct perf_counter_context *ctx = counter->ctx;
|
struct perf_counter_context *ctx = counter->ctx;
|
||||||
struct perf_counter *sibling;
|
struct perf_counter *sibling;
|
||||||
|
|
||||||
spin_lock_irq(&ctx->lock);
|
mutex_lock(&ctx->mutex);
|
||||||
counter = counter->group_leader;
|
counter = counter->group_leader;
|
||||||
|
|
||||||
func(counter);
|
func(counter);
|
||||||
list_for_each_entry(sibling, &counter->sibling_list, list_entry)
|
list_for_each_entry(sibling, &counter->sibling_list, list_entry)
|
||||||
func(sibling);
|
func(sibling);
|
||||||
spin_unlock_irq(&ctx->lock);
|
mutex_unlock(&ctx->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void perf_counter_for_each_child(struct perf_counter *counter,
|
static void perf_counter_for_each_child(struct perf_counter *counter,
|
||||||
@ -3414,7 +3416,10 @@ __perf_counter_exit_task(struct task_struct *child,
|
|||||||
struct perf_counter *parent_counter;
|
struct perf_counter *parent_counter;
|
||||||
|
|
||||||
update_counter_times(child_counter);
|
update_counter_times(child_counter);
|
||||||
|
|
||||||
|
spin_lock_irq(&child_ctx->lock);
|
||||||
list_del_counter(child_counter, child_ctx);
|
list_del_counter(child_counter, child_ctx);
|
||||||
|
spin_unlock_irq(&child_ctx->lock);
|
||||||
|
|
||||||
parent_counter = child_counter->parent;
|
parent_counter = child_counter->parent;
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user