workqueue changes for v3.14-rc1
Tejun Heo
maintainerHello, Linus.
Just one patch to add destroy_work_on_stack() annotations to help debugobj debugging. The change is almost trivial but unfortunately causes the following merge conflict.
long work_on_cpu(int cpu, long (*fn)(void *), void *arg)
{
struct work_for_cpu wfc = { .fn = fn, .arg = arg };
INIT_WORK_ONSTACK(&wfc.work, work_for_cpu_fn);
schedule_work_on(cpu, &wfc.work);
<<<<<<< HEAD
flush_work(&wfc.work);=======
/* * The work item is on-stack and can't lead to deadlock through * flushing. Use __flush_work() to avoid spurious lockdep warnings * when work_on_cpu()s are nested. */ __flush_work(&wfc.work); destroy_work_on_stack(&wfc.work);
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
440a11360326044a9addf1c652a0364aad0be90c
return wfc.ret;
}
The conflict is between the following two commits.
* master 12997d1a999c ("Revert "workqueue: allow work_on_cpu() to be called recursively"")
* wq/for-3.14 440a11360326 ("workqueue: Calling destroy_work_on_stack() to pair with INIT_WORK_ONSTACK()")
The former updated work_on_cpu() to drop __flush_work() change to allow recursive work_on_cpu() usage which no longer was necessary after PCI update. The latter added destroy_work_on_stack() call to the function thus causing context conflict. It can be easily resolved by adding destroy_work_on_stack() to the version in master.
long work_on_cpu(int cpu, long (*fn)(void *), void *arg)
{
struct work_for_cpu wfc = { .fn = fn, .arg = arg };
INIT_WORK_ONSTACK(&wfc.work, work_for_cpu_fn);
schedule_work_on(cpu, &wfc.work);
flush_work(&wfc.work);
destroy_work_on_stack(&wfc.work);
return wfc.ret;}
The merge is also available in the test-merge-3.14 branch of wq tree.
The changes are available in the following git branch.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-3.14
for you to fetch changes up to 440a11360326044a9addf1c652a0364aad0be90c:
workqueue: Calling destroy_work_on_stack() to pair with INIT_WORK_ONSTACK() (2014-01-11 22:26:33 -0500)
Thanks.
----------------------------------------------------------------
Chuansheng Liu (1):
workqueue: Calling destroy_work_on_stack() to pair with INIT_WORK_ONSTACK()
kernel/workqueue.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/workqueue.c +2 -0
@@ -4776,6 +4776,7 @@ static int workqueue_cpu_down_callback(struct notifier_block *nfb,/* wait for per-cpu unbinding to finish */ flush_work (&unbind_work); +destroy_work_on_stack (&unbind_work);break ; }return NOTIFY_OK ;
@@ -4822,6 +4823,7 @@ long work_on_cpu(int cpu, long (*fn)(void *), void *arg)*/ __flush_work (&wfc.work); +destroy_work_on_stack (&wfc.work);return wfc.ret; }EXPORT_SYMBOL_GPL (work_on_cpu);