mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-04-01 20:03:26 +00:00
workqueue: separate out init_rescuer()
Separate out init_rescuer() from __alloc_workqueue_key() to prepare for early init support for WQ_MEM_RECLAIM. This patch doesn't introduce any functional changes. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
This commit is contained in:
parent
b2cd1df660
commit
983c751532
1 changed files with 33 additions and 23 deletions
|
@ -3939,6 +3939,37 @@ static int wq_clamp_max_active(int max_active, unsigned int flags,
|
||||||
return clamp_val(max_active, 1, lim);
|
return clamp_val(max_active, 1, lim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Workqueues which may be used during memory reclaim should have a rescuer
|
||||||
|
* to guarantee forward progress.
|
||||||
|
*/
|
||||||
|
static int init_rescuer(struct workqueue_struct *wq)
|
||||||
|
{
|
||||||
|
struct worker *rescuer;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!(wq->flags & WQ_MEM_RECLAIM))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
rescuer = alloc_worker(NUMA_NO_NODE);
|
||||||
|
if (!rescuer)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
rescuer->rescue_wq = wq;
|
||||||
|
rescuer->task = kthread_create(rescuer_thread, rescuer, "%s", wq->name);
|
||||||
|
ret = PTR_ERR_OR_ZERO(rescuer->task);
|
||||||
|
if (ret) {
|
||||||
|
kfree(rescuer);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
wq->rescuer = rescuer;
|
||||||
|
kthread_bind_mask(rescuer->task, cpu_possible_mask);
|
||||||
|
wake_up_process(rescuer->task);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct workqueue_struct *__alloc_workqueue_key(const char *fmt,
|
struct workqueue_struct *__alloc_workqueue_key(const char *fmt,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
int max_active,
|
int max_active,
|
||||||
|
@ -4001,30 +4032,9 @@ 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)
|
||||||
* Workqueues which may be used during memory reclaim should
|
|
||||||
* have a rescuer to guarantee forward progress.
|
|
||||||
*/
|
|
||||||
if (flags & WQ_MEM_RECLAIM) {
|
|
||||||
struct worker *rescuer;
|
|
||||||
|
|
||||||
rescuer = alloc_worker(NUMA_NO_NODE);
|
|
||||||
if (!rescuer)
|
|
||||||
goto err_destroy;
|
goto err_destroy;
|
||||||
|
|
||||||
rescuer->rescue_wq = wq;
|
|
||||||
rescuer->task = kthread_create(rescuer_thread, rescuer, "%s",
|
|
||||||
wq->name);
|
|
||||||
if (IS_ERR(rescuer->task)) {
|
|
||||||
kfree(rescuer);
|
|
||||||
goto err_destroy;
|
|
||||||
}
|
|
||||||
|
|
||||||
wq->rescuer = rescuer;
|
|
||||||
kthread_bind_mask(rescuer->task, cpu_possible_mask);
|
|
||||||
wake_up_process(rescuer->task);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((wq->flags & WQ_SYSFS) && workqueue_sysfs_register(wq))
|
if ((wq->flags & WQ_SYSFS) && workqueue_sysfs_register(wq))
|
||||||
goto err_destroy;
|
goto err_destroy;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue