diff options
author | KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> | 2009-03-09 05:15:34 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-09 05:26:13 -0400 |
commit | c3ffc7a40b7e94b094efe1c8ab4e24370a782b65 (patch) | |
tree | 13e2831b866f1ee2ff1bc395400c87e2980225eb /kernel/trace/trace_workqueue.c | |
parent | 888b55dc314d26239d84c3b187dae555a81c1605 (diff) |
tracing: Don't use tracing_record_cmdline() in workqueue tracer
Impact: improve workqueue tracer output
Currently, /sys/kernel/debug/tracing/trace_stat/workqueues can display
wrong and strange thread names.
Why?
Currently, ftrace has tracing_record_cmdline()/trace_find_cmdline()
convenience function that implements a task->comm string cache.
This can avoid unnecessary memcpy overhead and the workqueue tracer
uses it.
However, in general, any trace statistics feature shouldn't use
tracing_record_cmdline() because trace statistics can display
very old process. Then comm cache can return wrong string because
recent process overrides the cache.
Fortunately, workqueue trace guarantees that displayed processes
are live. Thus we can search comm string from PID at display time.
<before>
% cat workqueues
# CPU INSERTED EXECUTED NAME
# | | | |
7 431913 431913 kondemand/7
7 0 0 tail
7 21 21 git
7 0 0 ls
7 9 9 cat
7 832632 832632 unix_chkpwd
7 236292 236292 ls
Note: tail, git, ls, cat unix_chkpwd are obiously not workqueue thread.
<after>
% cat workqueues
# CPU INSERTED EXECUTED NAME
# | | | |
7 510 510 kondemand/7
7 0 0 kmpathd/7
7 15 15 ata/7
7 0 0 aio/7
7 11 11 kblockd/7
7 1063 1063 work_on_cpu/7
7 167 167 events/7
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Steven Rostedt <srostedt@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_workqueue.c')
-rw-r--r-- | kernel/trace/trace_workqueue.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/kernel/trace/trace_workqueue.c b/kernel/trace/trace_workqueue.c index 4664990fe9c5..46c8dc896bd3 100644 --- a/kernel/trace/trace_workqueue.c +++ b/kernel/trace/trace_workqueue.c | |||
@@ -99,8 +99,6 @@ static void probe_workqueue_creation(struct task_struct *wq_thread, int cpu) | |||
99 | pr_warning("trace_workqueue: not enough memory\n"); | 99 | pr_warning("trace_workqueue: not enough memory\n"); |
100 | return; | 100 | return; |
101 | } | 101 | } |
102 | tracing_record_cmdline(wq_thread); | ||
103 | |||
104 | INIT_LIST_HEAD(&cws->list); | 102 | INIT_LIST_HEAD(&cws->list); |
105 | cws->cpu = cpu; | 103 | cws->cpu = cpu; |
106 | 104 | ||
@@ -195,11 +193,12 @@ static int workqueue_stat_show(struct seq_file *s, void *p) | |||
195 | struct cpu_workqueue_stats *cws = p; | 193 | struct cpu_workqueue_stats *cws = p; |
196 | unsigned long flags; | 194 | unsigned long flags; |
197 | int cpu = cws->cpu; | 195 | int cpu = cws->cpu; |
196 | struct task_struct *tsk = find_task_by_vpid(cws->pid); | ||
198 | 197 | ||
199 | seq_printf(s, "%3d %6d %6u %s\n", cws->cpu, | 198 | seq_printf(s, "%3d %6d %6u %s\n", cws->cpu, |
200 | atomic_read(&cws->inserted), | 199 | atomic_read(&cws->inserted), |
201 | cws->executed, | 200 | cws->executed, |
202 | trace_find_cmdline(cws->pid)); | 201 | tsk ? tsk->comm : "<...>"); |
203 | 202 | ||
204 | spin_lock_irqsave(&workqueue_cpu_stat(cpu)->lock, flags); | 203 | spin_lock_irqsave(&workqueue_cpu_stat(cpu)->lock, flags); |
205 | if (&cws->list == workqueue_cpu_stat(cpu)->list.next) | 204 | if (&cws->list == workqueue_cpu_stat(cpu)->list.next) |