Skip to contentSkip to conversation

sched/fair: scale vruntime delta on migration

RFC PATCH New Mathieu Desnoyers 1 participant 1 message Mar 13, 2023 Scheduler

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 sched/fair: scale vruntime delta on migration

On migration, use the respective runqueue spread of the source and destination runqueues to scale the vruntime delta of the scheduling entity.

The intent of this change is to prevent a task migrated from a very busy runqueue (with vruntime going fast) to a less busy runqueue (with a vruntime with a slower pace) to enqueue the migrated task far away at the very end of the runqueue, thus increasing the destination runqueue spread and preventing the enqueued task from being scheduled for a while until the vruntime reaches it.

The aim is to prevent long scheduling latencies on migration from busy to less busy runqueues.

This should help with asymmetric workloads showing spurious long scheduling latencies on large SMP systems.

[ Based on v6.1.18. ]
[ Testing/feedback welcome. ]

---
 include/linux/sched.h |  2 +
 kernel/sched/fair.c   | 86 +++++++++++++++++++++++++++++++++++--------
 kernel/sched/sched.h  |  1 +
 3 files changed, 74 insertions(+), 15 deletions(-)
include/linux/sched.h +2 -0
index ffb6eb55cd13..93e0b2dbe671 100644
@@ -558,6 +558,8 @@ struct sched_entity {
 
 	u64				nr_migrations;
 
+	u64				src_rq_spread;
+
 #ifdef CONFIG_FAIR_GROUP_SCHED
 	int				depth;
 	struct sched_entity		*parent;
kernel/sched/fair.c +71 -15

155 lines not on this page · raw message

kernel/sched/sched.h +1 -0
index d6d488e8eb55..6c657d371090 100644
@@ -556,6 +556,7 @@ struct cfs_rq {
 
 	u64			exec_clock;
 	u64			min_vruntime;
+	u64			vruntime_spread;
 #ifdef CONFIG_SCHED_CORE
 	unsigned int		forceidle_seq;
 	u64			min_vruntime_fi;
Signature · 1 line
2.25.1