[PATCH v2 23/35] sched: handle idle preemption for PREEMPT_AUTO

Ankur Arora posted 35 patches 1 year, 8 months ago
[PATCH v2 23/35] sched: handle idle preemption for PREEMPT_AUTO
Posted by Ankur Arora 1 year, 8 months ago
When running the idle task, we always want to schedule out immediately.
Use tif_resched(RESCHED_NOW) to do that.

This path should be identical across preemption models which is borne
out by comparing latency via perf bench sched pipe (5 runs):

PREEMPT_AUTO:	  4.430 usecs/op +-    0.080  ( +- 1.800% )
PREEMPT_DYNAMIC:  4.400 usecs/op +-    0.100  ( +- 2.270% )

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Originally-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/lkml/87jzshhexi.ffs@tglx/
Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
---
 kernel/sched/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index ee846dc9133b..1b930b84eb59 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1044,6 +1044,9 @@ static resched_t resched_opt_translate(struct task_struct *curr,
 	if (!IS_ENABLED(CONFIG_PREEMPT_AUTO))
 		return RESCHED_NOW;
 
+	if (is_idle_task(curr))
+		return RESCHED_NOW;
+
 	return RESCHED_LAZY;
 }
 
-- 
2.31.1