Skip to contentSkip to conversation

remove preempt in do_sched_yield

RFC In review Wang You 2 participants 2 messages Aug 23, 2023 – Aug 29, 2023 Scheduler

lore
Share & tools
lore

Wang You

author
#0 lore raw

RFC 1/1 remove preempt in do_sched_yield

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.

---
 kernel/sched/core.c | 3 ---
 1 file changed, 3 deletions(-)
kernel/sched/core.c +0 -3
index a68d1276bab0..b255e54c1d38 100644
@@ -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();
 
 	schedule();
 }
Signature · 1 line
2.20.1
#1 lore raw
Quoted 3 lines · On Wed, 23 Aug 2023 18:07:05 +0800 Wang You <[email protected]> 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?

Quoted 11 lines
---
 kernel/sched/core.c | 3 ---
 1 file changed, 3 deletions(-)
kernel/sched/core.c +0 -0
index a68d1276bab0..b255e54c1d38 100644

kernel/sched/core.c static void do_sched_yield(void) · line 8493

Quoted 7 lines
kernel/sched/core.c +0 -3
@@ -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

Quoted 3 lines
kernel/sched/core.c +0 -0
 	schedule();
 }