workqueue: fix deadlock in worker_maybe_bind_and_lock()
authorTejun Heo <tj@kernel.org>
Fri, 29 Apr 2011 16:08:37 +0000 (18:08 +0200)
committerSteve Conklin <sconklin@canonical.com>
Thu, 2 Jun 2011 19:23:10 +0000 (14:23 -0500)
commitf9f43f1ea23d5c45125939235a34abf088accb6f
tree5b449165a4e931778c670961a1622578618767d7
parenta02e3b98ac916d3d544c55f644c566aae2ad1918
workqueue: fix deadlock in worker_maybe_bind_and_lock()

BugLink: http://bugs.launchpad.net/bugs/780546

commit 5035b20fa5cd146b66f5f89619c20a4177fb736d upstream.

If a rescuer and stop_machine() bringing down a CPU race with each
other, they may deadlock on non-preemptive kernel.  The CPU won't
accept a new task, so the rescuer can't migrate to the target CPU,
while stop_machine() can't proceed because the rescuer is holding one
of the CPU retrying migration.  GCWQ_DISASSOCIATED is never cleared
and worker_maybe_bind_and_lock() retries indefinitely.

This problem can be reproduced semi reliably while the system is
entering suspend.

 http://thread.gmane.org/gmane.linux.kernel/1122051

A lot of kudos to Thilo-Alexander for reporting this tricky issue and
painstaking testing.

stable: This affects all kernels with cmwq, so all kernels since and
        including v2.6.36 need this fix.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Thilo-Alexander Ginkel <thilo@ginkel.com>
Tested-by: Thilo-Alexander Ginkel <thilo@ginkel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
kernel/workqueue.c