Messages in this thread Patch in this message | | | Date | Thu, 03 Feb 2011 15:09:43 +0100 | From | Peter Zijlstra <> | Subject | [PATCH 3/4] workqueue: Use mod_timer for queue_delayed_work() |
| |
Use mod_timer for queue_delayed_work(), this allows us to avoid calling cancel_delayed_work() prior to calling queue_delayed_work() when changing a work's expiration time.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <new-submission> --- Index: linux-2.6/kernel/workqueue.c =================================================================== --- linux-2.6.orig/kernel/workqueue.c +++ linux-2.6/kernel/workqueue.c @@ -1107,8 +1107,15 @@ static void delayed_work_timer_fn(unsign int queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay) { - if (delay == 0) + if (delay == 0) { + /* + * If the timer callback is currently running the work + * is already being enqueued and we don't actually have + * to do anything to make it run now... + */ + __cancel_delayed_work(dwork); return queue_work(wq, &dwork->work); + } return queue_delayed_work_on(-1, wq, dwork, delay); } @@ -1160,9 +1167,9 @@ int queue_delayed_work_on(int cpu, struc timer->function = delayed_work_timer_fn; if (unlikely(cpu >= 0)) - add_timer_on(timer, cpu); + mod_timer_on(timer, cpu); else - add_timer(timer); + mod_timer(timer); ret = 1; } return ret;
| |