Skip to contentSkip to conversation

sched_ext: switch class when preempted by higher priority scheduler

PATCH Applied Honglei Wang 3 participants 4 messages Jan 8, 2025 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sched_ext: switch class when preempted by higher priority scheduler

ops.cpu_release() function, if defined, must be invoked when preempted by a higher priority scheduler class task. This scenario was skipped in commit f422316d7466 ("sched_ext: Remove switch_class_scx()"). Let's fix it.

Fixes f422316d7466 ("sched_ext: Remove switch_class_scx()")
---
 kernel/sched/ext.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/ext.c +2 -1
index 19d2699cf638..ef0e3f2c1e6f 100644
@@ -3034,7 +3034,7 @@ static void put_prev_task_scx(struct rq *rq, struct task_struct *p,
 		 */
 		if (p->scx.slice && !scx_rq_bypassing(rq)) {
 			dispatch_enqueue(&rq->scx.local_dsq, p, SCX_ENQ_HEAD);
-			return;
+			goto switch_class;
 		}
 
 		/*
@@ -3051,6 +3051,7 @@ static void put_prev_task_scx(struct rq *rq, struct task_struct *p,
 		}
 	}
 
+switch_class:
 	if (next && next->sched_class != &ext_sched_class)
 		switch_class(rq, next);
 }
Signature · 1 line
2.45.2
Acked-by on v2 1/1
#1 lore raw

Hi Honglei,

Quoted 7 lines · Honglei Wang

ops.cpu_release() function, if defined, must be invoked when preempted by a higher priority scheduler class task. This scenario was skipped in commit f422316d7466 ("sched_ext: Remove switch_class_scx()"). Let's fix it.

Fixes f422316d7466 ("sched_ext: Remove switch_class_scx()")

Thanks a lot for catching this, I've also reproduced a stall (due to the missing ops.cpu_release() invocation) and verified that your fixes resolve the problem, so:

Quoted 28 lines
---
 kernel/sched/ext.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/ext.c +2 -1
index 19d2699cf638..ef0e3f2c1e6f 100644
@@ -3034,7 +3034,7 @@ static void put_prev_task_scx(struct rq *rq, struct task_struct *p,
 		 */
 		if (p->scx.slice && !scx_rq_bypassing(rq)) {
 			dispatch_enqueue(&rq->scx.local_dsq, p, SCX_ENQ_HEAD);
-			return;
+			goto switch_class;
 		}
 
 		/*
@@ -3051,6 +3051,7 @@ static void put_prev_task_scx(struct rq *rq, struct task_struct *p,
 		}
 	}
 
+switch_class:
 	if (next && next->sched_class != &ext_sched_class)
 		switch_class(rq, next);
 }
Signature · 1 line
2.45.2

-Andrea

#2 lore raw
Quoted 8 lines · Andrea Righi

Hi Honglei,

Quoted 5 lines · Honglei Wang

ops.cpu_release() function, if defined, must be invoked when preempted by a higher priority scheduler class task. This scenario was skipped in commit f422316d7466 ("sched_ext: Remove switch_class_scx()"). Let's fix it.

Quoted 9 lines
Quoted 2 lines
Fixes f422316d7466 ("sched_ext: Remove switch_class_scx()")

Thanks a lot for catching this, I've also reproduced a stall (due to the missing ops.cpu_release() invocation) and verified that your fixes resolve the problem, so:

Thanks a lot for looking at the code and the test, Andrea.

Quoted 30 lines
Quoted 28 lines
---
 kernel/sched/ext.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/ext.c +2 -1
index 19d2699cf638..ef0e3f2c1e6f 100644
@@ -3034,7 +3034,7 @@ static void put_prev_task_scx(struct rq *rq, struct task_struct *p,
 		 */
 		if (p->scx.slice && !scx_rq_bypassing(rq)) {
 			dispatch_enqueue(&rq->scx.local_dsq, p, SCX_ENQ_HEAD);
-			return;
+			goto switch_class;
 		}
 
 		/*
@@ -3051,6 +3051,7 @@ static void put_prev_task_scx(struct rq *rq, struct task_struct *p,
 		}
 	}
 
+switch_class:
 	if (next && next->sched_class != &ext_sched_class)
 		switch_class(rq, next);
 }
Signature · 1 line
2.45.2

-Andrea

Applied
#3 lore raw
In reply to Honglei Wang
Quoted 7 lines · Honglei Wang

ops.cpu_release() function, if defined, must be invoked when preempted by a higher priority scheduler class task. This scenario was skipped in commit f422316d7466 ("sched_ext: Remove switch_class_scx()"). Let's fix it.

Fixes f422316d7466 ("sched_ext: Remove switch_class_scx()")

Applied to sched_ext/for-6.13-fixes.

Thanks.

Signature · 1 line
tejun