]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
perf: Clean up 'ctx' reference counting
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Sat, 9 Apr 2011 19:17:41 +0000 (21:17 +0200)
committerIngo Molnar <mingo@elte.hu>
Sat, 28 May 2011 16:01:10 +0000 (18:01 +0200)
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>
kernel/events/core.c

index 4d9a1f014286083a938d836dc30c74ac7baed622..d665ac4242f24aa160a7b7842a8f04f91cdbc632 100644 (file)
@@ -2835,16 +2835,12 @@ retry:
                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);
                /*
@@ -2856,14 +2852,14 @@ retry:
                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;