Re: [RFC] remove preempt in do_sched_yield

From: Steven Rostedt
Date: Tue Aug 29 2023 - 14:43:15 EST


On Wed, 23 Aug 2023 18:07:05 +0800
Wang You <wangyoua@xxxxxxxxxxxxx> wrote:

> I see do_sched_yield's irq disable cover preempt disable. In this
> function, I think preempt op may not work, or it may have some
> special effect ? Thanks.

Why would it not work?

>
> Signed-off-by: Wang You <wangyoua@xxxxxxxxxxxxx>
> ---
> kernel/sched/core.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index a68d1276bab0..b255e54c1d38 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -8487,10 +8487,7 @@ static void do_sched_yield(void)
>
> schedstat_inc(rq->yld_count);
> current->sched_class->yield_task(rq);
> -
> - preempt_disable();
> rq_unlock_irq(rq, &rf);
> - sched_preempt_enable_no_resched();

The point of this is if an interrupt triggers here and NEED_RESCHED is
set, then it will call schedule and possibly schedule out the task.
When it gets scheduled back in, the first thing it will do is to call
schedule again. The above code you deleted removes the spurious
schedule.

-- Steve


>
> schedule();
> }