diff options
author | Tejun Heo <tj@kernel.org> | 2012-08-03 13:30:46 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2012-08-03 13:30:46 -0400 |
commit | 715f1300802e6eaefa85f6cfc70ae99af3d5d497 (patch) | |
tree | 1348231ae08bcb722e860aebe2e46a0565a86fd7 /kernel/workqueue.c | |
parent | 57469821fd5c61f25f783827d7334063cff67d65 (diff) |
workqueue: fix zero @delay handling of queue_delayed_work_on()
If @delay is zero and the dealyed_work is idle, queue_delayed_work()
queues it for immediate execution; however, queue_delayed_work_on()
lacks this logic and always goes through timer regardless of @delay.
This patch moves 0 @delay handling logic from queue_delayed_work() to
queue_delayed_work_on() so that both functions behave the same.
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r-- | kernel/workqueue.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index ce60bb5d12fb..6cbdc22f8ec7 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -1125,7 +1125,9 @@ EXPORT_SYMBOL_GPL(delayed_work_timer_fn); | |||
1125 | * @dwork: work to queue | 1125 | * @dwork: work to queue |
1126 | * @delay: number of jiffies to wait before queueing | 1126 | * @delay: number of jiffies to wait before queueing |
1127 | * | 1127 | * |
1128 | * Returns %false if @work was already on a queue, %true otherwise. | 1128 | * Returns %false if @work was already on a queue, %true otherwise. If |
1129 | * @delay is zero and @dwork is idle, it will be scheduled for immediate | ||
1130 | * execution. | ||
1129 | */ | 1131 | */ |
1130 | bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq, | 1132 | bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq, |
1131 | struct delayed_work *dwork, unsigned long delay) | 1133 | struct delayed_work *dwork, unsigned long delay) |
@@ -1135,6 +1137,9 @@ bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq, | |||
1135 | bool ret = false; | 1137 | bool ret = false; |
1136 | unsigned long flags; | 1138 | unsigned long flags; |
1137 | 1139 | ||
1140 | if (!delay) | ||
1141 | return queue_work_on(cpu, wq, &dwork->work); | ||
1142 | |||
1138 | /* read the comment in __queue_work() */ | 1143 | /* read the comment in __queue_work() */ |
1139 | local_irq_save(flags); | 1144 | local_irq_save(flags); |
1140 | 1145 | ||
@@ -1185,14 +1190,11 @@ EXPORT_SYMBOL_GPL(queue_delayed_work_on); | |||
1185 | * @dwork: delayable work to queue | 1190 | * @dwork: delayable work to queue |
1186 | * @delay: number of jiffies to wait before queueing | 1191 | * @delay: number of jiffies to wait before queueing |
1187 | * | 1192 | * |
1188 | * Returns %false if @work was already on a queue, %true otherwise. | 1193 | * Equivalent to queue_delayed_work_on() but tries to use the local CPU. |
1189 | */ | 1194 | */ |
1190 | bool queue_delayed_work(struct workqueue_struct *wq, | 1195 | bool queue_delayed_work(struct workqueue_struct *wq, |
1191 | struct delayed_work *dwork, unsigned long delay) | 1196 | struct delayed_work *dwork, unsigned long delay) |
1192 | { | 1197 | { |
1193 | if (delay == 0) | ||
1194 | return queue_work(wq, &dwork->work); | ||
1195 | |||
1196 | return queue_delayed_work_on(WORK_CPU_UNBOUND, wq, dwork, delay); | 1198 | return queue_delayed_work_on(WORK_CPU_UNBOUND, wq, dwork, delay); |
1197 | } | 1199 | } |
1198 | EXPORT_SYMBOL_GPL(queue_delayed_work); | 1200 | EXPORT_SYMBOL_GPL(queue_delayed_work); |