On 07/07/2011 10:43 AM, Somebody in the thread at some point said:
Not certain you meant this by "handled immediately" but to be clear
cancel_delayed_work() deletes the timer that creates the delay, and
stops the work ever from being executed. In that case the wakelock
will be left locked with nothing coming to unlock him except any
private wakelock timeout. And I am guessing private wakelock timeouts
are there to hide a whole bunch of immortal wakelocks due to broken
code that would otherwise kill suspend from ever happening.
The name cancel_delayed_work might be misleading but I learned that
although it deletes the timer, it still waits the work to be
finished. So in this case the wakelock is handled, no?
I think you're thinking about the flush... apis which do act like that.
But cancel... cancels.
2662 /**
2663 * cancel_delayed_work_sync - cancel a delayed work and wait for it
to finish
2664 * @dwork: the delayed work cancel
2665 *
2666 * This is cancel_work_sync() for delayed works.
2667 *
2668 * RETURNS:
2669 * %true if @dwork was pending, %false otherwise.
2670 */
2671 bool cancel_delayed_work_sync(struct delayed_work *dwork)
2672 {
2673 return __cancel_work_timer(&dwork->work, &dwork->timer);
2674 }
2675 EXPORT_SYMBOL(cancel_delayed_work_sync);
http://tomoyo.sourceforge.jp/cgi-bin/lxr/source/kernel/workqueue.c#L2671
2580 static bool __cancel_work_timer(struct work_struct *work,
2581 struct timer_list* timer)
2582 {
2583 int ret;
2584
2585 do {
2586 ret = (timer && likely(del_timer(timer)));
2587 if (!ret)
2588 ret = try_to_grab_pending(work);
2589 wait_on_work(work); <---
2590 } while (unlikely(ret < 0));
2591
2592 clear_work_data(work);
2593 return ret;
2594 }
http://tomoyo.sourceforge.jp/cgi-bin/lxr/source/kernel/workqueue.c#L2580
wait_on_work() -- another misleading name -- only waits in the case the
work is already running. If it hasn't run yet, it just returns.
I got the idea from looking at core.c it's full of bad corner cases
and potential problems wrt wakelock. I just wanted to confirm it
really does suck and it's not just me missing the point somewhere ^^
It does suck and it's not only you ;-)
I feel much better now ^^
-Andy
--
Andy Green | TI Landing Team Leader
Linaro.org │ Open source software for ARM SoCs | Follow Linaro
http://facebook.com/pages/Linaro/155974581091106 -
http://twitter.com/#!/linaroorg - http://linaro.org/linaro-blog
_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev