Skip to contentSkip to conversation

sched/fair: Fix pelt clock sync when entering idle

PATCH New Samuel Wu 1 participant 2 messages Mar 4 Stable branch

lore
Share & tools
lore

Samuel Wu

author
#0 lore raw

PATCH 1/1 sched/fair: Fix pelt clock sync when entering idle

From: Vincent Guittot <[email protected]>

[ Upstream commit 98c88dc8a1ace642d9021b103b28cba7b51e3abc ]

Samuel and Alex reported regressions of the util_avg of RT rq with commit 17e3e88ed0b6 ("sched/fair: Fix pelt lost idle time detection"). It happens that fair is updating and syncing the pelt clock with task one when pick_next_task_fair() fails to pick a task but before the prev scheduling class got a chance to update its pelt signals.

Move update_idle_rq_clock_pelt() in set_next_task_idle() which is called after prev class has been called.

[ wusamuel: Did not include line 'exec_start = rq_clock_task()', which is not present in 6.6.y but found in mainline ]

---
 kernel/sched/fair.c | 6 ------
 kernel/sched/idle.c | 6 ++++++
 2 files changed, 6 insertions(+), 6 deletions(-)
kernel/sched/fair.c +0 -6
index de205ecc1474..cdf49a04fd58 100644
@@ -8557,12 +8557,6 @@ done: __maybe_unused;
 			goto again;
 	}
 
-	/*
-	 * rq is about to be idle, check if we need to update the
-	 * lost_idle_time of clock_pelt
-	 */
-	update_idle_rq_clock_pelt(rq);
-
 	return NULL;
 }
 
kernel/sched/idle.c +6 -0
index 565f8374ddbb..038fbad93655 100644
@@ -414,6 +414,12 @@ static void set_next_task_idle(struct rq *rq, struct task_struct *next, bool fir
 {
 	update_idle_core(rq);
 	schedstat_inc(rq->sched_goidle);
+
+	/*
+	 * rq is about to be idle, check if we need to update the
+	 * lost_idle_time of clock_pelt
+	 */
+	update_idle_rq_clock_pelt(rq);
 }
 
 #ifdef CONFIG_SMP
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
author
#1 lore raw

PATCH 1/1 sched/fair: Fix pelt clock sync when entering idle

From: Vincent Guittot <[email protected]>

[ Upstream commit 98c88dc8a1ace642d9021b103b28cba7b51e3abc ]

Samuel and Alex reported regressions of the util_avg of RT rq with commit 17e3e88ed0b6 ("sched/fair: Fix pelt lost idle time detection"). It happens that fair is updating and syncing the pelt clock with task one when pick_next_task_fair() fails to pick a task but before the prev scheduling class got a chance to update its pelt signals.

Move update_idle_rq_clock_pelt() in set_next_task_idle() which is called after prev class has been called.

[ wusamuel: Did not include line 'exec_start = rq_clock_task()', which is not present in 6.1.y but found in mainline ]

---
 kernel/sched/fair.c | 6 ------
 kernel/sched/idle.c | 6 ++++++
 2 files changed, 6 insertions(+), 6 deletions(-)
kernel/sched/fair.c +0 -6
index 9f7c9083e9bf..376d835ca7b4 100644
@@ -7924,12 +7924,6 @@ done: __maybe_unused;
 			goto again;
 	}
 
-	/*
-	 * rq is about to be idle, check if we need to update the
-	 * lost_idle_time of clock_pelt
-	 */
-	update_idle_rq_clock_pelt(rq);
-
 	return NULL;
 }
 
kernel/sched/idle.c +6 -0
index 200a0fac03b8..6e76dc83a345 100644
@@ -435,6 +435,12 @@ static void set_next_task_idle(struct rq *rq, struct task_struct *next, bool fir
 {
 	update_idle_core(rq);
 	schedstat_inc(rq->sched_goidle);
+
+	/*
+	 * rq is about to be idle, check if we need to update the
+	 * lost_idle_time of clock_pelt
+	 */
+	update_idle_rq_clock_pelt(rq);
 }
 
 #ifdef CONFIG_SMP
Signature · 1 line
2.53.0.473.g4a7958ca14-goog