Re: [PATCH 14/14] workqueue: use mod_delayed_work() instead of cancel + queue

From: David Howells
Date: Mon Aug 13 2012 - 09:29:00 EST


Tejun Heo <tj@xxxxxxxxxx> wrote:

> Convert delayed_work users doing cancel_delayed_work() followed by
> queue_delayed_work() to mod_delayed_work().
>
> Most conversions are straight-forward. Ones worth mentioning are,
>
> * drivers/edac/edac_mc.c: edac_mc_workq_setup() converted to always
> use mod_delayed_work() and cancel loop in
> edac_mc_reset_delay_period() is dropped.
>
> * drivers/platform/x86/thinkpad_acpi.c: No need to remember whether
> watchdog is active or not. @fan_watchdog_active and related code
> dropped.
>
> * drivers/power/charger-manager.c: Seemingly a lot of
> delayed_work_pending() abuse going on here.
> [delayed_]work_pending() are unsynchronized and racy when used like
> this. I converted one instance in fullbatt_handler(). Please
> conver the rest so that it invokes workqueue APIs for the intended
> target state rather than trying to game work item pending state
> transitions. e.g. if timer should be modified - call
> mod_delayed_work(), canceled - call cancel_delayed_work[_sync]().
>
> * drivers/thermal/thermal_sys.c: thermal_zone_device_set_polling()
> simplified. Note that round_jiffies() calls in this function are
> meaningless. round_jiffies() work on absolute jiffies not delta
> delay used by delayed_work.
>
> v2: Tomi pointed out that __cancel_delayed_work() users can't be
> safely converted to mod_delayed_work(). They could be calling it
> from irq context and if that happens while delayed_work_timer_fn()
> is running, it could deadlock. __cancel_delayed_work() users are
> dropped.
>
> Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
> Acked-by: Henrique de Moraes Holschuh <hmh@xxxxxxxxxx>
> Acked-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
> Acked-by: Anton Vorontsov <cbouatmailru@xxxxxxxxx>

Acked-by: David Howells <dhowells@xxxxxxxxxx>
--
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/