Re: sched: Remove pointless preemption disable in sched_submit_work()

From: Lai Jiangshan
Date: Tue Sep 28 2021 - 21:26:28 EST


On Tue, Sep 28, 2021 at 10:31 PM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
> Neither wq_worker_sleeping() nor io_wq_worker_sleeping() require to be invoked
> with preemption disabled:
>
> - The worker flag checks operations only need to be serialized against
> the worker thread itself.
>
> - The accounting and worker pool operations are serialized with locks.
>
> which means that disabling preemption has neither a reason nor a
> value. Remove it.
>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> ---
> kernel/sched/core.c | 2 --
> 1 file changed, 2 deletions(-)
>
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -6327,12 +6327,10 @@ static inline void sched_submit_work(str
> * requires it.
> */
> if (task_flags & (PF_WQ_WORKER | PF_IO_WORKER)) {

Hello

The comment about preemption above this if branch and wq_worker_sleeping()
needs to be removed.

Thanks
Lai

Reviewed-by: Lai Jiangshan <jiangshanlai@xxxxxxxxx>

> - preempt_disable();
> if (task_flags & PF_WQ_WORKER)
> wq_worker_sleeping(tsk);
> else
> io_wq_worker_sleeping(tsk);
> - preempt_enable_no_resched();
> }
>
> if (tsk_is_pi_blocked(tsk))