Skip to contentSkip to conversation

workqueue: clear leftover flags when detached

PATCH Applied Lai Jiangshan 2 participants 2 messages Jun 3, 2014 – Jun 19, 2014 Workqueue

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 workqueue: clear leftover flags when detached

When a worker is detached, the worker->flags may still have WORKER_UNBOUND or WORKER_REBOUND, it is OK for all cases:
1) if it is a normal worker, the worker will be dead, it is OK.
2) if it is a rescuer, it may re-attach to a pool with this leftover flag[s], it is still correct except it may cause unneeded wakeup.

It is correct but not good, so we just remove the leftover flags.

---
 kernel/workqueue.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
kernel/workqueue.c +3 -0
index 7dc6e66..9f53abd 100644
@@ -1663,6 +1663,9 @@ static void worker_detach_from_pool(struct worker *worker,
 		detach_completion = pool->detach_completion;
 	mutex_unlock(&pool->attach_mutex);
 
+	/* clear leftover flags without pool->lock after it is detached */
+	worker->flags &= ~(WORKER_UNBOUND | WORKER_REBOUND);
+
 	if (detach_completion)
 		complete(detach_completion);
 }
Signature · 1 line
1.7.4.4
maintainer Applied
#1 lore raw
Quoted 9 lines · Lai Jiangshan

When a worker is detached, the worker->flags may still have WORKER_UNBOUND or WORKER_REBOUND, it is OK for all cases:
1) if it is a normal worker, the worker will be dead, it is OK.
2) if it is a rescuer, it may re-attach to a pool with this leftover flag[s], it is still correct except it may cause unneeded wakeup.

It is correct but not good, so we just remove the leftover flags.

Applied to wq/for-3.17.

Thanks.

Signature · 1 line
tejun