Re: [PATCH] cancel_delayed_work: use del_timer() instead of del_timer_sync()

From: Oleg Nesterov
Date: Fri Apr 27 2007 - 03:24:14 EST


On 04/27, Jarek Poplawski wrote:
>
> According to workqueue.h:
> > /*
> > * Kill off a pending schedule_delayed_work(). Note that the work callback
> > * function may still be running on return from cancel_delayed_work(). Run
> > * flush_workqueue() or cancel_work_sync() to wait on it.
> > */
> > static inline int cancel_delayed_work(struct delayed_work *work)
>
> So, we can do something like this:
>
> cancel_delayed_work(dwork);
> flush_workqueue(wq);
> kfree(some_obj_used_by_dwork_func);
>
> And this is enough to work with not rearming work.
>
> But no more after this patch...

Yes, you are right, and so this patch is wrong.

This is even documented in the changelog, with this change cancel_delayed_work()
may return while the queueing is in progress. However, in that case we can not
rely on flush_workqueue/cancel_work_sync.

Thanks a lot!

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/