Re: [PATCH] ftrace: do_each_pid_task() needs rcu lock

From: Oleg Nesterov
Date: Tue Feb 03 2009 - 14:44:57 EST


On 02/03, Oleg Nesterov wrote:
>
> "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.

Q: why do we use do_each_pid_task(PIDTYPE_PID) ? We can never have more
than 1 task in the loop. Perhaps,

static void set_ftrace_pid(struct pid *pid)
{
struct task_struct *p;

rcu_read_lock();
p = pid_task(pid, PIDTYPE_PID);
if (p)
set_tsk_trace_trace(p);
rcu_read_unlock();
}

looks better?

Oleg.

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