Skip to content

Commit

Permalink
perf: Clean up 'ctx' reference counting
Browse files Browse the repository at this point in the history
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: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20110409192141.719340481@chello.nl
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed May 28, 2011
1 parent 075e0b0 commit 9137fb2
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2835,16 +2835,12 @@ find_get_context(struct pmu *pmu, struct task_struct *task, int cpu)
unclone_ctx(ctx);
++ctx->pin_count;
raw_spin_unlock_irqrestore(&ctx->lock, flags);
}

if (!ctx) {
} else {
ctx = alloc_perf_context(pmu, task);
err = -ENOMEM;
if (!ctx)
goto errout;

get_ctx(ctx);

err = 0;
mutex_lock(&task->perf_event_mutex);
/*
Expand All @@ -2856,14 +2852,14 @@ find_get_context(struct pmu *pmu, struct task_struct *task, int cpu)
else if (task->perf_event_ctxp[ctxn])
err = -EAGAIN;
else {
get_ctx(ctx);
++ctx->pin_count;
rcu_assign_pointer(task->perf_event_ctxp[ctxn], ctx);
}
mutex_unlock(&task->perf_event_mutex);

if (unlikely(err)) {
put_task_struct(task);
kfree(ctx);
put_ctx(ctx);

if (err == -EAGAIN)
goto retry;
Expand Down

0 comments on commit 9137fb2

Please sign in to comment.