[PATCH 06/10] perf_counter: fix up counter free paths

From: Peter Zijlstra
Date: Thu Mar 19 2009 - 15:43:49 EST


I found another counter free path, create a free_counter() call to accomodate
generic tear-down.

Fixes an RCU bug.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
---
kernel/perf_counter.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

Index: linux-2.6/kernel/perf_counter.c
===================================================================
--- linux-2.6.orig/kernel/perf_counter.c
+++ linux-2.6/kernel/perf_counter.c
@@ -1150,6 +1150,11 @@ static void free_counter_rcu(struct rcu_
kfree(counter);
}

+static void free_counter(struct perf_counter *counter)
+{
+ call_rcu(&counter->rcu_head, free_counter_rcu);
+}
+
/*
* Called when the last reference to the file is gone.
*/
@@ -1168,7 +1173,7 @@ static int perf_release(struct inode *in
mutex_unlock(&counter->mutex);
mutex_unlock(&ctx->mutex);

- call_rcu(&counter->rcu_head, free_counter_rcu);
+ free_counter(counter);
put_context(ctx);

return 0;
@@ -2128,10 +2133,10 @@ __perf_counter_exit_task(struct task_str
list_entry) {
if (sub->parent) {
sync_child_counter(sub, sub->parent);
- kfree(sub);
+ free_counter(sub);
}
}
- kfree(child_counter);
+ free_counter(child_counter);
}
}


--

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/