[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250208080850.16300-1-15645113830zzh@gmail.com>
Date: Sat, 8 Feb 2025 16:08:52 +0800
From: zihan zhou <15645113830zzh@...il.com>
To: mingo@...hat.com,
peterz@...radead.org,
juri.lelli@...hat.com,
vincent.guittot@...aro.org,
dietmar.eggemann@....com,
rostedt@...dmis.org,
bsegall@...gle.com,
mgorman@...e.de,
vschneid@...hat.com
Cc: linux-kernel@...r.kernel.org,
zihan zhou <15645113830zzh@...il.com>
Subject: [PATCH V2] sched: Cancel the slice protection of the idle entity
A wakeup non-idle entity should preempt idle entity at any time,
but because of the slice protection of the idle entity, the non-idle
entity has to wait, so just cancel it.
This patch is aimed at minimizing the impact of SCHED_IDLE on
SCHED_NORMAL. For example, a task with SCHED_IDLE policy that sleeps for
1s and then runs for 3 ms, running cyclictest on the same cpu, has a
maximum latency of 3 ms, which is caused by the slice protection of the
idle entity. It is unreasonable. With this patch, the cyclictest latency
under the same conditions is basically the same on the cpu with idle
processes and on empty cpu.
Fixes: 63304558ba5d ("sched/eevdf: Curb wakeup-preemption")
Signed-off-by: zihan zhou <15645113830zzh@...il.com>
Reviewed-by: Vincent Guittot <vincent.guittot@...aro.org>
Tested-by: Vincent Guittot <vincent.guittot@...aro.org>
---
kernel/sched/fair.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 1e78caa21436..41e1c18a8e6a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8762,8 +8762,17 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
* Preempt an idle entity in favor of a non-idle entity (and don't preempt
* in the inverse case).
*/
- if (cse_is_idle && !pse_is_idle)
+ if (cse_is_idle && !pse_is_idle) {
+ /*
+ * When non-idle entity preempt an idle entity,
+ * don't give idle entity slice protection.
+ */
+ if (se->vlag == se->deadline)
+ se->vlag = se->deadline + 1;
+
goto preempt;
+ }
+
if (cse_is_idle != pse_is_idle)
return;
--
2.33.0
Powered by blists - more mailing lists