Re: [PATCH] tracing/workqueue: Get rid of searching last executedworklet in probe_worklet_complete()

From: Oleg Nesterov
Date: Thu May 21 2009 - 09:10:06 EST


On 05/21, Zhaolei wrote:
>
> 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.

Minor nit,

> @@ -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;

Suppose that "enqueue" handler fails to allocate the memory for the new
work_struct.

This means that the "execute" handler does not record ->last_workfunc.

In that case probe_worklet_complete() uses the wrong workfunc_stats or
we can even crash if ->last_workfunc == NULL.

I think _execute() should set ->last_workfunc = NULL first, then serach
for wfnode. _complete() should check ->last_workfunc != NULL and return
if it is NULL.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/