workqueue: clear POOL_DISASSOCIATED in rebind_workers()
PATCH 1/2 workqueue: clear POOL_DISASSOCIATED in rebind_workers()
The commit a9ab775bcadf ("workqueue: directly restore CPU affinity of workers from CPU_ONLINE") moved the pool->lock into rebind_workers() without also moving "pool->flags &= ~POOL_DISASSOCIATED" into.
There is no wrong that "pool->flags &= ~POOL_DISASSOCIATED" is kept outside, but there is no benefit either. We move it into rebind_workers() and achieve these benefits:
1) better readability, POOL_DISASSOCIATED is cleared in rebind_workers() as supposed.
2) when POOL_DISASSOCIATED is cleared, we can ensure that the running
workers of the pool are on the local CPU (pool->cpu).
--- kernel/workqueue.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
kernel/workqueue.c +1 -4
@@ -4535,6 +4535,7 @@ static void rebind_workers(struct worker_pool *pool) pool->attrs->cpumask) < 0);spin_lock_irq (&pool->lock); + pool->flags &= ~POOL_DISASSOCIATED ;for_each_pool_worker (worker, pool) {unsigned int worker_flags = worker->flags;
@@ -4637,10 +4638,6 @@ static int workqueue_cpu_up_callback(struct notifier_block *nfb,mutex_lock (&pool->attach_mutex);if (pool->cpu == cpu) { -spin_lock_irq (&pool->lock); - pool->flags &= ~POOL_DISASSOCIATED ; -spin_unlock_irq (&pool->lock); -rebind_workers (pool); }else if (pool->cpu <0 ) {restore_unbound_workers_cpumask (pool, cpu);
Signature · 1 line
1.7.4.4
PATCH 2/2 workqueue: stronger test in process_one_work()
When POOL_DISASSOCIATED is cleared, the running worker's local CPU should be the same as pool->cpu without any exception even during cpu-hotplug.
This fix changes "(proposition_A && proposition_B && proposition_C)" to "(proposition_B && proposition_C)", so if the old compound proposition is true, the new one must be true too. so this fix will not hide any possible bug which can be hit by old test.
--- kernel/workqueue.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)
kernel/workqueue.c +2 -7
@@ -2015,13 +2015,8 @@ __acquires(&pool->lock)lockdep_copy_map (&lockdep_map, &work->lockdep_map);#endif -/* -* Ensure we're on the correct CPU. DISASSOCIATED test is -* necessary to avoid spurious warnings from rescuers servicing the -* unbound or a disassociated pool. -*/ -WARN_ON_ONCE (!(worker->flags &WORKER_UNBOUND ) && - !(pool->flags &POOL_DISASSOCIATED ) && +/* Ensure we're on the correct CPU. */ +WARN_ON_ONCE (!(pool->flags &POOL_DISASSOCIATED ) &&raw_smp_processor_id () != pool->cpu);/*
Signature · 1 line
1.7.4.4
Re: [PATCH 2/2] workqueue: stronger test in process_one_work()
Quoted 11 lines · Lai Jiangshan
When
POOL_DISASSOCIATEDis cleared, the running worker's local CPU should be the same aspool->cpuwithout any exception even during cpu-hotplug.This fix changes "(
proposition_A&&proposition_B&&proposition_C)" to "(proposition_B&&proposition_C)", so if the old compound proposition is true, the new one must be true too. so this fix will not hide any possible bug which can be hit by old test.CC Jason J. Herne <[email protected]>CC Sasha Levin <[email protected]>Signed-off-by Lai Jiangshan <[email protected]>
Applied to wq/for-3.17 with minor updates.
Nice set of cleanups. Thanks!
Signature · 1 line
tejun
Re: [PATCH 2/2] workqueue: stronger test in process_one_work()
Quoted 9 lines · Tejun Heo
Quoted 8 lines · Lai Jiangshan
When
POOL_DISASSOCIATEDis cleared, the running worker's local CPU should be the same aspool->cpuwithout any exception even during cpu-hotplug.This fix changes "(
proposition_A&&proposition_B&&proposition_C)" to "(proposition_B&&proposition_C)", so if the old compound proposition is true, the new one must be true too. so this fix will not hide any possible bug which can be hit by old test.
Quoted 8 lines
Quoted 3 lines
CC Jason J. Herne <[email protected]>CC Sasha Levin <[email protected]>Signed-off-by Lai Jiangshan <[email protected]>Applied to wq/for-3.17 with minor updates.
Nice set of cleanups. Thanks!
Hi,Tejun
I found the slight earlier 6 patches are in wq/for-3.17.
But these two patches (in this email thread) are not in wq/for-3.17 yet.
workqueue: clear POOL_DISASSOCIATED in rebind_workers()
workqueue: stronger test in process_one_work()
Thanks,
Lai
Re: [PATCH 2/2] workqueue: stronger test in process_one_work()
Ping.
Thanks,
Lai
Quoted 35 lines · Lai Jiangshan
Quoted 9 lines · Tejun Heo
Quoted 8 lines · Lai Jiangshan
When
POOL_DISASSOCIATEDis cleared, the running worker's local CPU should be the same aspool->cpuwithout any exception even during cpu-hotplug.This fix changes "(
proposition_A&&proposition_B&&proposition_C)" to "(proposition_B&&proposition_C)", so if the old compound proposition is true, the new one must be true too. so this fix will not hide any possible bug which can be hit by old test.Quoted 8 lines
Quoted 3 lines
CC Jason J. Herne <[email protected]>CC Sasha Levin <[email protected]>Signed-off-by Lai Jiangshan <[email protected]>Applied to wq/for-3.17 with minor updates.
Nice set of cleanups. Thanks!
Hi,Tejun
I found the slight earlier 6 patches are in wq/for-3.17.
But these two patches (in this email thread) are not in wq/for-3.17 yet.workqueue: clear
POOL_DISASSOCIATEDinrebind_workers()
workqueue: stronger test inprocess_one_work()Thanks,
Lai
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] workqueue: stronger test in process_one_work()
In reply to Lai JiangshanQuoted 11 lines · Lai Jiangshan
When
POOL_DISASSOCIATEDis cleared, the running worker's local CPU should be the same aspool->cpuwithout any exception even during cpu-hotplug.This fix changes "(
proposition_A&&proposition_B&&proposition_C)" to "(proposition_B&&proposition_C)", so if the old compound proposition is true, the new one must be true too. so this fix will not hide any possible bug which can be hit by old test.CC Jason J. Herne <[email protected]>CC Sasha Levin <[email protected]>Signed-off-by Lai Jiangshan <[email protected]>
Oops, thought I applied them.
Applied to wq/for-3.17 w/ minor updates.
Thanks.
Signature · 1 line
tejun