[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7b105f07-5c13-4f69-9834-05e7054ddb36@redhat.com>
Date: Wed, 3 Jul 2024 11:14:44 -0400
From: Waiman Long <longman@...hat.com>
To: Lai Jiangshan <jiangshanlai@...il.com>, linux-kernel@...r.kernel.org
Cc: Lai Jiangshan <jiangshan.ljs@...group.com>, Tejun Heo <tj@...nel.org>
Subject: Re: [PATCH 2/6] workqueue: Protect wq_unbound_cpumask with
wq_pool_attach_mutex in init_rescuer()
On 7/2/24 23:38, Lai Jiangshan wrote:
> From: Lai Jiangshan <jiangshan.ljs@...group.com>
>
> wq_unbound_cpumask can be possibly changed without wq_pool_attach_mutex
> or wq_pool_mutex held in init_rescuer().
>
> Use wq_pool_attach_mutex to protect it.
>
> Fixes: 49584bb8ddbe("workqueue: Bind unbound workqueue rescuer to wq_unbound_cpumask")
> Signed-off-by: Lai Jiangshan <jiangshan.ljs@...group.com>
> ---
> kernel/workqueue.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index c738b3024cc2..cf1a129eb547 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -5533,6 +5533,9 @@ static int init_rescuer(struct workqueue_struct *wq)
> return ret;
> }
>
> + /* lock wq_pool_attach_mutex for wq_unbound_cpumask */
> + mutex_lock(&wq_pool_attach_mutex);
> +
> wq->rescuer = rescuer;
> if (wq->flags & WQ_UNBOUND)
> kthread_bind_mask(rescuer->task, wq_unbound_cpumask);
> @@ -5540,6 +5543,8 @@ static int init_rescuer(struct workqueue_struct *wq)
> kthread_bind_mask(rescuer->task, cpu_possible_mask);
> wake_up_process(rescuer->task);
>
> + mutex_unlock(&wq_pool_attach_mutex);
> +
> return 0;
> }
>
Reviewed-by: Waiman Long <longman@...hat.com>
Thanks!
Powered by blists - more mailing lists