]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ftrace: do_each_pid_task() needs rcu lock
authorOleg Nesterov <oleg@redhat.com>
Tue, 3 Feb 2009 19:39:04 +0000 (20:39 +0100)
committerIngo Molnar <mingo@elte.hu>
Tue, 3 Feb 2009 21:50:58 +0000 (22:50 +0100)
"ftrace: use struct pid" commit 978f3a45d9499c7a447ca7615455cefb63d44165
converted ftrace_pid_trace to "struct pid*".

But we can't use do_each_pid_task() without rcu_read_lock() even if
we know the pid itself can't go away (it was pinned in ftrace_pid_write).
The exiting task can detach itself from this pid at any moment.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/trace/ftrace.c

index 7dcf6e9f2b04f46527c7e1a69e1a8bd9fc0c8a0e..9a236ffe2aa45188cacabfc8fbc15e81c6091f64 100644 (file)
@@ -1737,9 +1737,12 @@ static void clear_ftrace_pid(struct pid *pid)
 {
        struct task_struct *p;
 
+       rcu_read_lock();
        do_each_pid_task(pid, PIDTYPE_PID, p) {
                clear_tsk_trace_trace(p);
        } while_each_pid_task(pid, PIDTYPE_PID, p);
+       rcu_read_unlock();
+
        put_pid(pid);
 }
 
@@ -1747,9 +1750,11 @@ static void set_ftrace_pid(struct pid *pid)
 {
        struct task_struct *p;
 
+       rcu_read_lock();
        do_each_pid_task(pid, PIDTYPE_PID, p) {
                set_tsk_trace_trace(p);
        } while_each_pid_task(pid, PIDTYPE_PID, p);
+       rcu_read_unlock();
 }
 
 static void clear_ftrace_pid_task(struct pid **pid)