All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched_ext:SCX is preemptible by the Fair scheduler
@ 2026-06-12 17:51 Cui Jian
  2026-06-12 18:00 ` Andrea Righi
  2026-06-12 18:05 ` sashiko-bot
  0 siblings, 2 replies; 8+ messages in thread
From: Cui Jian @ 2026-06-12 17:51 UTC (permalink / raw)
  To: tj, void
  Cc: arighi, changwoo, mingo, peterz, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
	kprateek.nayak, sched-ext, linux-kernel, Cui Jian

Hi Andrea,

While this callback will eventually be deprecated, SCX is still a relatively new scheduling framework. Incomplete preemption reason enums make it difficult to analyze interactions between different schedulers, and filling this gap significantly improves observability for existing SCX workloads.

This patch does not modify core scheduling logic, introduces zero performance overhead, and adds negligible long-term maintenance cost.

sched_ext currently distinguishes preemption caused by STOP,
DL and RT scheduling classes, but preemption from the Fair
scheduler is reported as SCX_CPU_PREEMPT_UNKNOWN.

When analyzing SCX scheduling behavior, it is useful to know
whether a task was preempted by RT/DL classes or switched out
in favor of a Fair-class task. The lack of a dedicated reason
makes debugging and observability more difficult.

Add SCX_CPU_PREEMPT_FAIR and report it when the next scheduled
task belongs to fair_sched_class.

This change improves scheduling diagnostics and observability
without affecting scheduling behavior.

Signed-off-by: Cui Jian <cjian720@163.com>
---
 kernel/sched/ext.c          | 2 ++
 kernel/sched/ext_internal.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 5d2d19473a82..6e0281218197 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -3015,6 +3015,8 @@ preempt_reason_from_class(const struct sched_class *class)
 		return SCX_CPU_PREEMPT_DL;
 	if (class == &rt_sched_class)
 		return SCX_CPU_PREEMPT_RT;
+	if (class == &fair_sched_class)
+		return SCX_CPU_PREEMPT_FAIR;
 	return SCX_CPU_PREEMPT_UNKNOWN;
 }
 
diff --git a/kernel/sched/ext_internal.h b/kernel/sched/ext_internal.h
index a075732d4430..3ce07bec58a5 100644
--- a/kernel/sched/ext_internal.h
+++ b/kernel/sched/ext_internal.h
@@ -241,6 +241,8 @@ enum scx_cpu_preempt_reason {
 	SCX_CPU_PREEMPT_DL,
 	/* next task is being scheduled by &sched_class_stop */
 	SCX_CPU_PREEMPT_STOP,
+	/* next task is being scheduled by &sched_class_fair*/
+	SCX_CPU_PREEMPT_FAIR,
 	/* unknown reason for SCX being preempted */
 	SCX_CPU_PREEMPT_UNKNOWN,
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH] sched_ext:SCX is preemptible by the Fair scheduler
@ 2026-06-12 16:14 Cui Jian
  2026-06-12 16:28 ` sashiko-bot
  2026-06-12 16:32 ` Andrea Righi
  0 siblings, 2 replies; 8+ messages in thread
From: Cui Jian @ 2026-06-12 16:14 UTC (permalink / raw)
  To: tj, void
  Cc: arighi, changwoo, mingo, peterz, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
	kprateek.nayak, sched-ext, linux-kernel, Cui Jian

sched_ext currently distinguishes preemption caused by STOP,
DL and RT scheduling classes, but preemption from the Fair
scheduler is reported as SCX_CPU_PREEMPT_UNKNOWN.

When analyzing SCX scheduling behavior, it is useful to know
whether a task was preempted by RT/DL classes or switched out
in favor of a Fair-class task. The lack of a dedicated reason
makes debugging and observability more difficult.

Add SCX_CPU_PREEMPT_FAIR and report it when the next scheduled
task belongs to fair_sched_class.

This change improves scheduling diagnostics and observability
without affecting scheduling behavior.

Signed-off-by: Cui Jian <cjian720@163.com>
---
 kernel/sched/ext.c          | 2 ++
 kernel/sched/ext_internal.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 5d2d19473a82..6e0281218197 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -3015,6 +3015,8 @@ preempt_reason_from_class(const struct sched_class *class)
 		return SCX_CPU_PREEMPT_DL;
 	if (class == &rt_sched_class)
 		return SCX_CPU_PREEMPT_RT;
+	if (class == &fair_sched_class)
+		return SCX_CPU_PREEMPT_FAIR;
 	return SCX_CPU_PREEMPT_UNKNOWN;
 }
 
diff --git a/kernel/sched/ext_internal.h b/kernel/sched/ext_internal.h
index a075732d4430..3ce07bec58a5 100644
--- a/kernel/sched/ext_internal.h
+++ b/kernel/sched/ext_internal.h
@@ -241,6 +241,8 @@ enum scx_cpu_preempt_reason {
 	SCX_CPU_PREEMPT_DL,
 	/* next task is being scheduled by &sched_class_stop */
 	SCX_CPU_PREEMPT_STOP,
+	/* next task is being scheduled by &sched_class_fair*/
+	SCX_CPU_PREEMPT_FAIR,
 	/* unknown reason for SCX being preempted */
 	SCX_CPU_PREEMPT_UNKNOWN,
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH] sched_ext:SCX is preemptible by the Fair scheduler
@ 2026-06-12 15:23 Cui Jian
  2026-06-12 15:38 ` sashiko-bot
  0 siblings, 1 reply; 8+ messages in thread
From: Cui Jian @ 2026-06-12 15:23 UTC (permalink / raw)
  To: tj, void
  Cc: arighi, changwoo, mingo, peterz, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
	kprateek.nayak, sched-ext, linux-kernel, Cui Jian

sched_ext currently distinguishes preemption caused by STOP,
DL and RT scheduling classes, but preemption from the Fair
scheduler is reported as SCX_CPU_PREEMPT_UNKNOWN.

When analyzing SCX scheduling behavior, it is useful to know
whether a task was preempted by RT/DL classes or switched out
in favor of a Fair-class task. The lack of a dedicated reason
makes debugging and observability more difficult.

Add SCX_CPU_PREEMPT_FAIR and report it when the next scheduled
task belongs to fair_sched_class.

This change improves scheduling diagnostics and observability
without affecting scheduling behavior.

Signed-off-by: Cui Jian <cjian720@163.com>
---
 kernel/sched/ext.c          | 2 ++
 kernel/sched/ext_internal.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 5d2d19473a82..6e0281218197 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -3015,6 +3015,8 @@ preempt_reason_from_class(const struct sched_class *class)
 		return SCX_CPU_PREEMPT_DL;
 	if (class == &rt_sched_class)
 		return SCX_CPU_PREEMPT_RT;
+	if (class == &fair_sched_class)
+		return SCX_CPU_PREEMPT_FAIR;
 	return SCX_CPU_PREEMPT_UNKNOWN;
 }
 
diff --git a/kernel/sched/ext_internal.h b/kernel/sched/ext_internal.h
index a075732d4430..3ce07bec58a5 100644
--- a/kernel/sched/ext_internal.h
+++ b/kernel/sched/ext_internal.h
@@ -241,6 +241,8 @@ enum scx_cpu_preempt_reason {
 	SCX_CPU_PREEMPT_DL,
 	/* next task is being scheduled by &sched_class_stop */
 	SCX_CPU_PREEMPT_STOP,
+	/* next task is being scheduled by &sched_class_fair*/
+	SCX_CPU_PREEMPT_FAIR,
 	/* unknown reason for SCX being preempted */
 	SCX_CPU_PREEMPT_UNKNOWN,
 };
-- 
2.34.1


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

end of thread, other threads:[~2026-06-12 18:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-12 17:51 [PATCH] sched_ext:SCX is preemptible by the Fair scheduler Cui Jian
2026-06-12 18:00 ` Andrea Righi
2026-06-12 18:05 ` sashiko-bot
  -- strict thread matches above, loose matches on Subject: below --
2026-06-12 16:14 Cui Jian
2026-06-12 16:28 ` sashiko-bot
2026-06-12 16:32 ` Andrea Righi
2026-06-12 15:23 Cui Jian
2026-06-12 15:38 ` sashiko-bot

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.