on top of
Add cpu-relax() into spinloops, and a comments update.
Small note. The new implementation has another downside. Suppose that rearming
work->func() gets a preemtion after setting WORK_STRUCT_PENDING but before
add_timer/__queue_work. In that case cancel_rearming_delayed_work() will burn
CPU in a busy-wait loop. Fortunately this can happen only with CONFIG_PREEMPT
and we spin with preemption enabled.
We can avoid this,
void cancel_rearming_delayed_work(struct delayed_work *dwork)
retry = !del_timer(&dwork->timer) &&
} while (retry);
but I don't think this is worth fixing.
Signed-off-by: Oleg Nesterov <[email protected]>
--- OLD/kernel/workqueue.c~2_RELAX 2007-05-05 23:17:48.000000000 +0400
+++ OLD/kernel/workqueue.c 2007-05-05 23:59:59.000000000 +0400
@@ -475,13 +475,16 @@ static void wait_on_work(struct work_str
* case it only guarantees that work->func() has completed on the last queued
+ * cancel_work_sync(&delayed_work->work) should be used only if ->timer is not
+ * pending, otherwise it goes into a busy-wait loop until the timer expires.
* The caller must ensure that workqueue_struct on which this work was last
* queued can't be destroyed before this function returns.
void cancel_work_sync(struct work_struct *work)
@@ -498,7 +501,7 @@ void cancel_rearming_delayed_work(struct
while (!del_timer(&dwork->timer) &&
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Video 4 Linux]
[Linux for the blind]