unsigned long *flags)
{
struct worker_pool *pool;
+ struct cpu_workqueue_struct *cwq;
local_irq_save(*flags);
goto fail;
spin_lock(&pool->lock);
- if (!list_empty(&work->entry)) {
- /*
- * This work is queued, but perhaps we locked the wrong
- * pool. In that case we must see the new value after
- * rmb(), see insert_work()->wmb().
- */
- smp_rmb();
- if (pool == get_work_pool(work)) {
+ /*
+ * work->data is guaranteed to point to cwq only while the work
+ * item is queued on cwq->wq, and both updating work->data to point
+ * to cwq on queueing and to pool on dequeueing are done under
+ * cwq->pool->lock. This in turn guarantees that, if work->data
+ * points to cwq which is associated with a locked pool, the work
+ * item is currently queued on that pool.
+ */
+ cwq = get_work_cwq(work);
+ if (cwq) {
+ if (cwq->pool == pool) {
debug_work_deactivate(work);
/*
/* we own @work, set data and link */
set_work_cwq(work, cwq, extra_flags);
-
- /*
- * Ensure that we get the right work->data if we see the
- * result of list_add() below, see try_to_grab_pending().
- */
- smp_wmb();
-
list_add_tail(&work->entry, head);
/*
return false;
spin_lock_irq(&pool->lock);
- if (!list_empty(&work->entry)) {
- /*
- * See the comment near try_to_grab_pending()->smp_rmb().
- * If it was re-queued to a different pool under us, we
- * are not going to wait.
- */
- smp_rmb();
- cwq = get_work_cwq(work);
- if (unlikely(!cwq || pool != cwq->pool))
+ /* see the comment in try_to_grab_pending() with the same code */
+ cwq = get_work_cwq(work);
+ if (cwq) {
+ if (unlikely(cwq->pool != pool))
goto already_gone;
} else {
worker = find_worker_executing_work(pool, work);