History

Merge branch 'for-3.9-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq

Pull workqueue fix from Tejun Heo: "Lai's patch to fix highly unlikely but still possible workqueue stall during CPU hotunplug." * 'for-3.9-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq: workqueue: fix possible pool stall bug in wq_unbind_fn()

Linus Torvalds committed 13 years ago

Commit b63dc122 parents 35f8c76 eb283421 file · +25 −19Browse files

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

Unified · Split

kernel/workqueue.c+25−19
@@ -3447,28 +3447,34 @@ static void wq_unbind_fn(struct work_struct *work) · 3446 unmodified lines
34473447
34483448 spin_unlock_irq(&pool->lock);
34493449 mutex_unlock(&pool->assoc_mutex);
3450− }
34513450
3452− /*
3453− * Call schedule() so that we cross rq->lock and thus can guarantee
3454− * sched callbacks see the %WORKER_UNBOUND flag. This is necessary
3455− * as scheduler callbacks may be invoked from other cpus.
3456− */
3457− schedule();
3451+ /*
3452+ * Call schedule() so that we cross rq->lock and thus can
3453+ * guarantee sched callbacks see the %WORKER_UNBOUND flag.
3454+ * This is necessary as scheduler callbacks may be invoked
3455+ * from other cpus.
3456+ */
3457+ schedule();
34583458
3459− /*
3460− * Sched callbacks are disabled now. Zap nr_running. After this,
3461− * nr_running stays zero and need_more_worker() and keep_working()
3462− * are always true as long as the worklist is not empty. Pools on
3463− * @cpu now behave as unbound (in terms of concurrency management)
3464− * pools which are served by workers tied to the CPU.
3465− *
3466− * On return from this function, the current worker would trigger
3467− * unbound chain execution of pending work items if other workers
3468− * didn't already.
3469− */
3470− for_each_std_worker_pool(pool, cpu)
3459+ /*
3460+ * Sched callbacks are disabled now. Zap nr_running.
3461+ * After this, nr_running stays zero and need_more_worker()
3462+ * and keep_working() are always true as long as the
3463+ * worklist is not empty. This pool now behaves as an
3464+ * unbound (in terms of concurrency management) pool which
3465+ * are served by workers tied to the pool.
3466+ */
34713467 atomic_set(&pool->nr_running, 0);
3468+
3469+ /*
3470+ * With concurrency management just turned off, a busy
3471+ * worker blocking could lead to lengthy stalls. Kick off
3472+ * unbound chain execution of currently pending work items.
3473+ */
3474+ spin_lock_irq(&pool->lock);
3475+ wake_up_worker(pool);
3476+ spin_unlock_irq(&pool->lock);
3477+ }
34723478 }
34733479
34743480 /*