History

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.

Tejun Heo committed 14 years ago

Commit 715f1301 parent 57469821 file · +7 −5Browse files

Showing the changes to kernel/workqueue.c (1 of 1 file). Show all

Unified · Split

kernel/workqueue.c+7−5
@@ -1125,7 +1125,9 @@ EXPORT_SYMBOL_GPL(delayed_work_timer_fn); · 1124 unmodified lines
11251125 * @dwork: work to queue
11261126 * @delay: number of jiffies to wait before queueing
11271127 *
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.
11291131 */
11301132 bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
11311133 struct delayed_work *dwork, unsigned long delay)
@@ -1135,6 +1137,9 @@ bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq, · 3 unmodified lines
11351137 bool ret = false;
11361138 unsigned long flags;
11371139
1140+ if (!delay)
1141+ return queue_work_on(cpu, wq, &dwork->work);
1142+
11381143 /* read the comment in __queue_work() */
11391144 local_irq_save(flags);
11401145
@@ -1185,14 +1190,11 @@ EXPORT_SYMBOL_GPL(queue_delayed_work_on); · 44 unmodified lines
11851190 * @dwork: delayable work to queue
11861191 * @delay: number of jiffies to wait before queueing
11871192 *
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.
11891194 */
11901195 bool queue_delayed_work(struct workqueue_struct *wq,
11911196 struct delayed_work *dwork, unsigned long delay)
11921197 {
1193− if (delay == 0)
1194− return queue_work(wq, &dwork->work);
1195−
11961198 return queue_delayed_work_on(WORK_CPU_UNBOUND, wq, dwork, delay);
11971199 }
11981200 EXPORT_SYMBOL_GPL(queue_delayed_work);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t