public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracing/workqueue: Get rid of searching last executed worklet in probe_worklet_complete()
@ 2009-05-21 10:56 Zhaolei
  2009-05-21 13:05 ` Oleg Nesterov
  2009-05-22  2:40 ` [PATCH v2] tracing/workqueue: Get rid of searching last executed worklet " Zhaolei
  0 siblings, 2 replies; 8+ messages in thread
From: Zhaolei @ 2009-05-21 10:56 UTC (permalink / raw)
  To: Frederic Weisbecker, Steven Rostedt, Ingo Molnar, Tom Zanussi,
	Oleg Nesterov
  Cc: LKML

We don't need search workqueue's worklet list for worklet which was latest
executed, instead, we can use a pointer in cpu_workqueue_stats to remember
which worklet was just executed.

Thanks Oleg for pointing it out.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Reported-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/trace/trace_workqueue.c |   37 +++++++++++++------------------------
 1 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/kernel/trace/trace_workqueue.c b/kernel/trace/trace_workqueue.c
index c67be60..d90f9ac 100644
--- a/kernel/trace/trace_workqueue.c
+++ b/kernel/trace/trace_workqueue.c
@@ -25,13 +25,6 @@ struct workfunc_stats {
 	unsigned int			inserted;
 	unsigned int			executed;
 
-	/*
-	 * save latest work_struct's pointer to use as identifier in
-	 * probe_worklet_complete, because we can't use work_struct->...
-	 * after worklet got executed
-	 */
-	void				*work;
-
 	/* save execution time temporarily for calculate executed time */
 	u64				start_time;
 	u64				max_executed_time;
@@ -46,10 +39,17 @@ struct cpu_workqueue_stats {
 	/* Protected by cpu workqueue lock */
 	unsigned int		inserted;
 	unsigned int		executed;
+
 	/* list of struct workfunc_stats in this workqueue */
 	struct list_head	workfunclist;
 
 	/*
+	 * pointer to last executed worklet's workfunc_stats in this workqueue,
+	 * used by probe_worklet_complete()
+	 */
+	struct workfunc_stats *last_workfunc;
+
+	/*
 	 * the task maybe destroyed when we read stat file
 	 * we define it to void * because we only use it as a identifier
 	 */
@@ -163,7 +163,7 @@ found_wq:
 		if (wfnode->func == work->func) {
 			wfnode->executed++;
 			wfnode->start_time = trace_clock_global();
-			wfnode->work = work;
+			node->last_workfunc = wfnode;
 			goto found_wf;
 		}
 	pr_debug("trace_workqueue: worklet not found\n");
@@ -180,7 +180,7 @@ probe_worklet_complete(struct task_struct *wq_thread, void *work)
 {
 	int cpu = cpumask_first(&wq_thread->cpus_allowed);
 	struct cpu_workqueue_stats *node;
-	struct workfunc_stats *wfnode;
+	u64 executed_time;
 	unsigned long flags;
 
 	spin_lock_irqsave(&workqueue_cpu_stat(cpu)->lock, flags);
@@ -192,22 +192,11 @@ probe_worklet_complete(struct task_struct *wq_thread, void *work)
 	goto end;
 
 found_wq:
-	list_for_each_entry(wfnode, &node->workfunclist, list) {
-		u64 executed_time;
+	executed_time = trace_clock_global() - node->last_workfunc->start_time;
+	node->last_workfunc->total_time += executed_time;
+	if (executed_time > node->last_workfunc->max_executed_time)
+		node->last_workfunc->max_executed_time = executed_time;
 
-		if (wfnode->work != work)
-			continue;
-
-		executed_time = trace_clock_global() - wfnode->start_time;
-		wfnode->total_time += executed_time;
-		if (executed_time > wfnode->max_executed_time)
-			wfnode->max_executed_time = executed_time;
-		goto found_wf;
-	}
-	pr_debug("trace_workqueue: worklet not found\n");
-	goto end;
-
-found_wf:
 end:
 	spin_unlock_irqrestore(&workqueue_cpu_stat(cpu)->lock, flags);
 }
-- 
1.5.5.3



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

end of thread, other threads:[~2009-05-27 18:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-21 10:56 [PATCH] tracing/workqueue: Get rid of searching last executed worklet in probe_worklet_complete() Zhaolei
2009-05-21 13:05 ` Oleg Nesterov
2009-05-22  0:42   ` [PATCH] tracing/workqueue: Get rid of searching last executedworklet " Zhaolei
2009-05-22  2:40 ` [PATCH v2] tracing/workqueue: Get rid of searching last executed worklet " Zhaolei
2009-05-22 18:37   ` Oleg Nesterov
2009-05-26 20:23     ` Frederic Weisbecker
2009-05-27 18:32       ` Oleg Nesterov
2009-05-24 21:30   ` Frederic Weisbecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox