All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/fair: favor non-idle group in tick preemption
@ 2022-10-27  8:16 Chuyi Zhou
  2022-10-27 23:34 ` Josh Don
  0 siblings, 1 reply; 14+ messages in thread
From: Chuyi Zhou @ 2022-10-27  8:16 UTC (permalink / raw)
  To: peterz, juri.lelli, mingo, vincent.guittot
  Cc: linux-kernel, joshdon, Chuyi Zhou

The non-idle se dominates competition vs the idle se when they
are belong to the same group. We ensure that idle groups would not
preempt non-idle group in wakeup preemption(see check_preempt_wakeup()).
However, this can happen in tick preemption, since check_preempt_tick()
dose not check current/se is idle or not. This patch adds this check.

Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
---
 kernel/sched/fair.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index e4a0b8bd941c..f3324b8753b3 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4750,6 +4750,7 @@ static void
 check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
 {
 	unsigned long ideal_runtime, delta_exec;
+	int cse_is_idle, pse_is_idle;
 	struct sched_entity *se;
 	s64 delta;
 
@@ -4779,8 +4780,17 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
 	if (delta < 0)
 		return;
 
-	if (delta > ideal_runtime)
+	if (delta > ideal_runtime) {
+		/*
+		 * Favor non-idle group even in tick preemption
+		 */
+		cse_is_idle = se_is_idle(curr);
+		pse_is_idle = se_is_idle(se);
+		if (unlikely(!cse_is_idle && pse_is_idle))
+			return;
+
 		resched_curr(rq_of(cfs_rq));
+	}
 }
 
 static void
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-11-11 19:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27  8:16 [PATCH] sched/fair: favor non-idle group in tick preemption Chuyi Zhou
2022-10-27 23:34 ` Josh Don
2022-10-28  3:57   ` Chuyi Zhou
2022-10-28 22:40     ` Josh Don
2022-10-31  8:39       ` Chuyi Zhou
2022-10-31 22:44         ` Josh Don
2022-11-01  3:45           ` Chuyi Zhou
2022-11-01 23:39             ` Josh Don
2022-11-03 11:24               ` Chuyi Zhou
2022-11-04  3:49               ` [External] " Hao Jia
2022-11-04 21:25                 ` Josh Don
2022-11-11  3:50               ` Abel Wu
2022-11-11 19:14                 ` Josh Don
2022-11-01  9:14           ` Abel Wu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.