path: root/block/genhd.c
diff options
authorTejun Heo <>2012-08-03 10:30:47 -0700
committerTejun Heo <>2012-08-13 16:27:37 -0700
commit41f63c5359d14ca995172b8f6eaffd93f60fec54 (patch)
treed3d93dfd25d2e29e8abeae934835f2266b018cb7 /block/genhd.c
parent8376fe22c7e79c7e90857d39f82aeae6cad6c4b8 (diff)
workqueue: use mod_delayed_work() instead of cancel + queue
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 <> Acked-by: Henrique de Moraes Holschuh <> Acked-by: Dmitry Torokhov <> Acked-by: Anton Vorontsov <> Acked-by: David Howells <> Cc: Tomi Valkeinen <> Cc: Jens Axboe <> Cc: Jiri Kosina <> Cc: Doug Thompson <> Cc: David Airlie <> Cc: Roland Dreier <> Cc: "John W. Linville" <> Cc: Zhang Rui <> Cc: Len Brown <> Cc: "J. Bruce Fields" <> Cc: Johannes Berg <>
Diffstat (limited to 'block/genhd.c')
1 files changed, 2 insertions, 4 deletions
diff --git a/block/genhd.c b/block/genhd.c
index cac7366957c3..5d8b44a6442b 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1534,10 +1534,8 @@ void disk_flush_events(struct gendisk *disk, unsigned int mask)
ev->clearing |= mask;
- if (!ev->block) {
- cancel_delayed_work(&ev->dwork);
- queue_delayed_work(system_nrt_freezable_wq, &ev->dwork, 0);
- }
+ if (!ev->block)
+ mod_delayed_work(system_nrt_freezable_wq, &ev->dwork, 0);