public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ftrace: do_each_pid_task() needs rcu lock
@ 2009-02-03 19:39 Oleg Nesterov
  2009-02-03 19:42 ` Oleg Nesterov
  2009-02-03 21:51 ` Ingo Molnar
  0 siblings, 2 replies; 7+ messages in thread
From: Oleg Nesterov @ 2009-02-03 19:39 UTC (permalink / raw)
  To: Ingo Molnar, Steven Rostedt; +Cc: Eric W. Biederman, linux-kernel

"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>

--- 6.29-rc3/kernel/trace/ftrace.c~FTRACE_PID	2009-01-12 23:07:51.000000000 +0100
+++ 6.29-rc3/kernel/trace/ftrace.c	2009-02-03 20:23:59.000000000 +0100
@@ -1736,9 +1736,12 @@ static void clear_ftrace_pid(struct 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);
 }
 
@@ -1746,9 +1749,11 @@ static void set_ftrace_pid(struct pid *p
 {
 	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)


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-02-04  0:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-03 19:39 [PATCH] ftrace: do_each_pid_task() needs rcu lock Oleg Nesterov
2009-02-03 19:42 ` Oleg Nesterov
2009-02-03 21:39   ` Eric W. Biederman
2009-02-03 22:28     ` Oleg Nesterov
2009-02-03 23:30       ` Eric W. Biederman
2009-02-04  0:12         ` Oleg Nesterov
2009-02-03 21:51 ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox