workqueue: allow WQ_MEM_RECLAIM on early init workqueues

Workqueues can be created early during boot before workqueue subsystem
in fully online - work items are queued waiting for later full
initialization.  However, early init wasn't supported for
WQ_MEM_RECLAIM workqueues causing unnecessary annoyances for a subset
of users.  Expand early init support to include WQ_MEM_RECLAIM
workqueues.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
This commit is contained in:
Tejun Heo 2018-01-08 05:38:37 -08:00
parent 983c751532
commit 40c17f75df

View file

@ -4032,7 +4032,7 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt,
if (alloc_and_link_pwqs(wq) < 0) if (alloc_and_link_pwqs(wq) < 0)
goto err_free_wq; goto err_free_wq;
if (init_rescuer(wq) < 0) if (wq_online && init_rescuer(wq) < 0)
goto err_destroy; goto err_destroy;
if ((wq->flags & WQ_SYSFS) && workqueue_sysfs_register(wq)) if ((wq->flags & WQ_SYSFS) && workqueue_sysfs_register(wq))
@ -5639,6 +5639,8 @@ int __init workqueue_init(void)
* archs such as power and arm64. As per-cpu pools created * archs such as power and arm64. As per-cpu pools created
* previously could be missing node hint and unbound pools NUMA * previously could be missing node hint and unbound pools NUMA
* affinity, fix them up. * affinity, fix them up.
*
* Also, while iterating workqueues, create rescuers if requested.
*/ */
wq_numa_init(); wq_numa_init();
@ -5650,8 +5652,12 @@ int __init workqueue_init(void)
} }
} }
list_for_each_entry(wq, &workqueues, list) list_for_each_entry(wq, &workqueues, list) {
wq_update_unbound_numa(wq, smp_processor_id(), true); wq_update_unbound_numa(wq, smp_processor_id(), true);
WARN(init_rescuer(wq),
"workqueue: failed to create early rescuer for %s",
wq->name);
}
mutex_unlock(&wq_pool_mutex); mutex_unlock(&wq_pool_mutex);