perfcounters: fix refcounting bug
authorMike Galbraith <efault@gmx.de>
Thu, 29 Jan 2009 13:06:52 +0000 (14:06 +0100)
committerIngo Molnar <mingo@elte.hu>
Thu, 29 Jan 2009 13:25:23 +0000 (14:25 +0100)
don't kfree in use counters.

Running...

while true; do perfstat -e 1 -c true; done

...on all cores for a while doesn't seem to be eating ram, and my oops
is gone.

Signed-off-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/perf_counter.c

index 1ac18da..f27a7e9 100644 (file)
@@ -1934,7 +1934,8 @@ __perf_counter_exit_task(struct task_struct *child,
                }
        }
 
-       kfree(child_counter);
+       if (!child_counter->filp || !atomic_long_read(&child_counter->filp->f_count))
+               kfree(child_counter);
 }
 
 /*