Commit 6af8bf3d authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

workqueues: add comments to __create_workqueue_key()

Dmitry Adamushko pointed out that the error handling in
__create_workqueue_key() is not clear, add the comment.
Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
Cc: Dmitry Adamushko <dmitry.adamushko@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent dbacefc9
...@@ -830,10 +830,21 @@ struct workqueue_struct *__create_workqueue_key(const char *name, ...@@ -830,10 +830,21 @@ struct workqueue_struct *__create_workqueue_key(const char *name,
start_workqueue_thread(cwq, -1); start_workqueue_thread(cwq, -1);
} else { } else {
cpu_maps_update_begin(); cpu_maps_update_begin();
/*
* We must place this wq on list even if the code below fails.
* cpu_down(cpu) can remove cpu from cpu_populated_map before
* destroy_workqueue() takes the lock, in that case we leak
* cwq[cpu]->thread.
*/
spin_lock(&workqueue_lock); spin_lock(&workqueue_lock);
list_add(&wq->list, &workqueues); list_add(&wq->list, &workqueues);
spin_unlock(&workqueue_lock); spin_unlock(&workqueue_lock);
/*
* We must initialize cwqs for each possible cpu even if we
* are going to call destroy_workqueue() finally. Otherwise
* cpu_up() can hit the uninitialized cwq once we drop the
* lock.
*/
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
cwq = init_cpu_workqueue(wq, cpu); cwq = init_cpu_workqueue(wq, cpu);
if (err || !cpu_online(cpu)) if (err || !cpu_online(cpu))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment