tracing: Don't use tracing_record_cmdline() in workqueue tracer fix
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Fri, 13 Mar 2009 00:03:04 +0000 (09:03 +0900)
committerSteven Rostedt <srostedt@redhat.com>
Fri, 13 Mar 2009 01:23:47 +0000 (21:23 -0400)
commit c3ffc7a40b7e94b094efe1c8ab4e24370a782b65
"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>
kernel/trace/trace_workqueue.c

index fb5ccac8bbc0e9af264c53d06e173ff1f7fd2b32..9ab035b58cf1425b4b817dfae37d0b36e5eeada3 100644 (file)
@@ -193,12 +193,20 @@ static int workqueue_stat_show(struct seq_file *s, void *p)
        struct cpu_workqueue_stats *cws = p;
        unsigned long flags;
        int cpu = cws->cpu;
-       struct task_struct *tsk = find_task_by_vpid(cws->pid);
-
-       seq_printf(s, "%3d %6d     %6u       %s\n", cws->cpu,
-                  atomic_read(&cws->inserted),
-                  cws->executed,
-                  tsk ? tsk->comm : "<...>");
+       struct pid *pid;
+       struct task_struct *tsk;
+
+       pid = find_get_pid(cws->pid);
+       if (pid) {
+               tsk = get_pid_task(pid, PIDTYPE_PID);
+               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);
        if (&cws->list == workqueue_cpu_stat(cpu)->list.next)