tracing: Don't use tracing_record_cmdline() in workqueue tracer fix

commit c3ffc7a40b
"Don't use tracing_record_cmdline() in workqueue tracer"
has a race window.

find_task_by_vpid() requires task_list_lock().

LKML-Reference: <20090313090042.43CD.A69D9226@jp.fujitsu.com>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
This commit is contained in:
KOSAKI Motohiro 2009-03-13 09:03:04 +09:00 committed by Steven Rostedt
parent 39842323ce
commit 889a6c3672

View File

@ -193,12 +193,20 @@ static int workqueue_stat_show(struct seq_file *s, void *p)
struct cpu_workqueue_stats *cws = p; struct cpu_workqueue_stats *cws = p;
unsigned long flags; unsigned long flags;
int cpu = cws->cpu; int cpu = cws->cpu;
struct task_struct *tsk = find_task_by_vpid(cws->pid); struct pid *pid;
struct task_struct *tsk;
seq_printf(s, "%3d %6d %6u %s\n", cws->cpu, pid = find_get_pid(cws->pid);
atomic_read(&cws->inserted), if (pid) {
cws->executed, tsk = get_pid_task(pid, PIDTYPE_PID);
tsk ? tsk->comm : "<...>"); if (tsk) {
seq_printf(s, "%3d %6d %6u %s\n", cws->cpu,
atomic_read(&cws->inserted), cws->executed,
tsk->comm);
put_task_struct(tsk);
}
put_pid(pid);
}
spin_lock_irqsave(&workqueue_cpu_stat(cpu)->lock, flags); spin_lock_irqsave(&workqueue_cpu_stat(cpu)->lock, flags);
if (&cws->list == workqueue_cpu_stat(cpu)->list.next) if (&cws->list == workqueue_cpu_stat(cpu)->list.next)