]> git.baikalelectronics.ru Git - kernel.git/commit
workqueue: implement mod_delayed_work[_on]()
authorTejun Heo <tj@kernel.org>
Fri, 3 Aug 2012 17:30:47 +0000 (10:30 -0700)
committerTejun Heo <tj@kernel.org>
Fri, 3 Aug 2012 17:30:47 +0000 (10:30 -0700)
commitd5b10679cee6181d70a531e910bdf039436ca890
tree3a77fda11324a25abfe1ffe3ea0eba28a4fac03f
parentdc1752dcab2ca76f03da62a7d33b2dc7be3f533c
workqueue: implement mod_delayed_work[_on]()

Workqueue was lacking a mechanism to modify the timeout of an already
pending delayed_work.  delayed_work users have been working around
this using several methods - using an explicit timer + work item,
messing directly with delayed_work->timer, and canceling before
re-queueing, all of which are error-prone and/or ugly.

This patch implements mod_delayed_work[_on]() which behaves similarly
to mod_timer() - if the delayed_work is idle, it's queued with the
given delay; otherwise, its timeout is modified to the new value.
Zero @delay guarantees immediate execution.

v2: Updated to reflect try_to_grab_pending() changes.  Now safe to be
    called from bh context.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
include/linux/workqueue.h
kernel/workqueue.c