lkml.org 
[lkml]   [2011]   [Feb]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
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;



\
 
 \ /
  Last update: 2011-02-03 15:21    [W:0.086 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site