workqueue: Fix PF_THREAD_BOUND abuse
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Mon, 3 Oct 2011 10:43:25 +0000 (12:43 +0200)
committerClark Williams <williams@redhat.com>
Wed, 15 Feb 2012 16:32:58 +0000 (10:32 -0600)
commitd1cea53b7182b5e55633b2de147fbbf2c249dcff
treed43a0210d0ad8f919b9f579dac61f7aed06d6346
parented29a9e7dc0c6d8712d5e318e00d7400405f9da4
workqueue: Fix PF_THREAD_BOUND abuse

PF_THREAD_BOUND is set by kthread_bind() and means the thread is bound
to a particular cpu for correctness. The workqueue code abuses this
flag and blindly sets it for all created threads, including those that
are free to migrate.

Restore the original semantics now that the worst abuse in the
cpu-hotplug path are gone. The only icky bit is the rescue thread for
per-cpu workqueues, this cannot use kthread_bind() but will use
set_cpus_allowed_ptr() to migrate itself to the desired cpu.

Set and clear PF_THREAD_BOUND manually here.

XXX: I think worker_maybe_bind_and_lock()/worker_unbind_and_unlock()
should also do a get_online_cpus(), this would likely allow us to
remove the while loop.

XXX: should probably repurpose GCWQ_DISASSOCIATED to warn on adding
works after CPU_DOWN_PREPARE -- its dual use to mark unbound gcwqs is
a tad annoying though.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/workqueue.c