Commit 9137fb28 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

perf: Clean up 'ctx' reference counting

Small cleanup to how we refcount in find_get_context(), this also
allows us to use put_ctx() to free things instead of using kfree().
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20110409192141.719340481@chello.nlSigned-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 075e0b00
...@@ -2835,16 +2835,12 @@ find_get_context(struct pmu *pmu, struct task_struct *task, int cpu) ...@@ -2835,16 +2835,12 @@ find_get_context(struct pmu *pmu, struct task_struct *task, int cpu)
unclone_ctx(ctx); unclone_ctx(ctx);
++ctx->pin_count; ++ctx->pin_count;
raw_spin_unlock_irqrestore(&ctx->lock, flags); raw_spin_unlock_irqrestore(&ctx->lock, flags);
} } else {
if (!ctx) {
ctx = alloc_perf_context(pmu, task); ctx = alloc_perf_context(pmu, task);
err = -ENOMEM; err = -ENOMEM;
if (!ctx) if (!ctx)
goto errout; goto errout;
get_ctx(ctx);
err = 0; err = 0;
mutex_lock(&task->perf_event_mutex); mutex_lock(&task->perf_event_mutex);
/* /*
...@@ -2856,14 +2852,14 @@ find_get_context(struct pmu *pmu, struct task_struct *task, int cpu) ...@@ -2856,14 +2852,14 @@ find_get_context(struct pmu *pmu, struct task_struct *task, int cpu)
else if (task->perf_event_ctxp[ctxn]) else if (task->perf_event_ctxp[ctxn])
err = -EAGAIN; err = -EAGAIN;
else { else {
get_ctx(ctx);
++ctx->pin_count; ++ctx->pin_count;
rcu_assign_pointer(task->perf_event_ctxp[ctxn], ctx); rcu_assign_pointer(task->perf_event_ctxp[ctxn], ctx);
} }
mutex_unlock(&task->perf_event_mutex); mutex_unlock(&task->perf_event_mutex);
if (unlikely(err)) { if (unlikely(err)) {
put_task_struct(task); put_ctx(ctx);
kfree(ctx);
if (err == -EAGAIN) if (err == -EAGAIN)
goto retry; goto retry;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment