All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for tip] tracing: Don't use tracing_record_cmdline() in workqueue tracer fix
@ 2009-03-13  0:03 KOSAKI Motohiro
  2009-03-13  0:48 ` Steven Rostedt
  2009-03-13  4:03 ` [tip:tracing/ftrace] " KOSAKI Motohiro
  0 siblings, 2 replies; 3+ messages in thread
From: KOSAKI Motohiro @ 2009-03-13  0:03 UTC (permalink / raw)
  To: LKML; +Cc: kosaki.motohiro, Ingo Molnar, Steven Rostedt, Frederic Weisbecker


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

find_task_by_vpid() require task_list_lock(). but the patch doesn't.

fixing here.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
 kernel/trace/trace_workqueue.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/trace_workqueue.c b/kernel/trace/trace_workqueue.c
index fb5ccac..9ab035b 100644
--- a/kernel/trace/trace_workqueue.c
+++ b/kernel/trace/trace_workqueue.c
@@ -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)
-- 
1.6.0.6




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

* Re: [PATCH for tip] tracing: Don't use tracing_record_cmdline() in workqueue tracer fix
  2009-03-13  0:03 [PATCH for tip] tracing: Don't use tracing_record_cmdline() in workqueue tracer fix KOSAKI Motohiro
@ 2009-03-13  0:48 ` Steven Rostedt
  2009-03-13  4:03 ` [tip:tracing/ftrace] " KOSAKI Motohiro
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2009-03-13  0:48 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: LKML, Ingo Molnar, Frederic Weisbecker


On Fri, 2009-03-13 at 09:03 +0900, KOSAKI Motohiro wrote:
> commit c3ffc7a40b7e94b094efe1c8ab4e24370a782b65 "Don't use tracing_record_cmdline() 
> in workqueue tracer" have a race window.
> 
> find_task_by_vpid() require task_list_lock(). but the patch doesn't.
> 
> fixing here.
> 
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> ---

Applied, thanks!

-- Steve



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

* [tip:tracing/ftrace] tracing: Don't use tracing_record_cmdline() in workqueue tracer fix
  2009-03-13  0:03 [PATCH for tip] tracing: Don't use tracing_record_cmdline() in workqueue tracer fix KOSAKI Motohiro
  2009-03-13  0:48 ` Steven Rostedt
@ 2009-03-13  4:03 ` KOSAKI Motohiro
  1 sibling, 0 replies; 3+ messages in thread
From: KOSAKI Motohiro @ 2009-03-13  4:03 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, srostedt, tglx, kosaki.motohiro

Commit-ID:  889a6c367283709a80dad9413488472596a1a1d2
Gitweb:     http://git.kernel.org/tip/889a6c367283709a80dad9413488472596a1a1d2
Author:     KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
AuthorDate: Fri, 13 Mar 2009 09:03:04 +0900
Commit:     Steven Rostedt <srostedt@redhat.com>
CommitDate: Thu, 12 Mar 2009 21:23:47 -0400

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

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 |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/trace_workqueue.c b/kernel/trace/trace_workqueue.c
index fb5ccac..9ab035b 100644
--- a/kernel/trace/trace_workqueue.c
+++ b/kernel/trace/trace_workqueue.c
@@ -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)

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

end of thread, other threads:[~2009-03-13  4:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-13  0:03 [PATCH for tip] tracing: Don't use tracing_record_cmdline() in workqueue tracer fix KOSAKI Motohiro
2009-03-13  0:48 ` Steven Rostedt
2009-03-13  4:03 ` [tip:tracing/ftrace] " KOSAKI Motohiro

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.