Skip to content

Commit

Permalink
ftrace: do_each_pid_task() needs rcu lock
Browse files Browse the repository at this point in the history
"ftrace: use struct pid" commit 978f3a4
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 <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
oleg-nesterov authored and Ingo Molnar committed Feb 3, 2009
1 parent b1792e3 commit 229c4ef
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1737,19 +1737,24 @@ 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);
}

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)
Expand Down

0 comments on commit 229c4ef

Please sign in to comment.