* [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; 4+ 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] 4+ messages in thread* Re: [PATCH] sched_ext:SCX is preemptible by the Fair scheduler
2026-06-12 16:14 [PATCH] sched_ext:SCX is preemptible by the Fair scheduler Cui Jian
@ 2026-06-12 16:28 ` sashiko-bot
2026-06-12 16:32 ` Andrea Righi
1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-06-12 16:28 UTC (permalink / raw)
To: Cui Jian; +Cc: sched-ext
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch adds `SCX_CPU_PREEMPT_FAIR` to `enum scx_cpu_preempt_reason` in `kernel/sched/ext_internal.h`, but fails to update the checked-in autogenerated BPF tool headers in `tools/sched_ext/include/scx/enum_defs.autogen.h`.
--
commit 0e9cc05c20430d666c8c1a1d7ea0741d9c28b2d3
Author: Cui Jian <cjian720@163.com>
sched_ext:SCX is preemptible by the Fair scheduler
This commit adds a new preemption reason, SCX_CPU_PREEMPT_FAIR, to distinguish
when a sched_ext task is preempted by the Fair scheduler. It updates the
internal enum and mapping function to improve observability and diagnostics.
> diff --git a/kernel/sched/ext_internal.h b/kernel/sched/ext_internal.h
> index a075732d4430d..3ce07bec58a55 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,
[Severity: Medium]
Should tools/sched_ext/include/scx/enum_defs.autogen.h be regenerated
and included in this patch?
When adding a new value to enum scx_cpu_preempt_reason, the autogenerated
BPF tool headers typically need updating so downstream BPF schedulers can
use feature detection macros like HAVE_SCX_CPU_PREEMPT_FAIR.
Without this update, BPF applications cannot conditionally check for this
new preemption feature across different kernel versions.
> /* unknown reason for SCX being preempted */
> SCX_CPU_PREEMPT_UNKNOWN,
> };
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260612161403.105775-1-cjian720@163.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] sched_ext:SCX is preemptible by the Fair scheduler
2026-06-12 16:14 [PATCH] sched_ext:SCX is preemptible by the Fair scheduler Cui Jian
2026-06-12 16:28 ` sashiko-bot
@ 2026-06-12 16:32 ` Andrea Righi
[not found] ` <4a81ba55.9be4.19ebce4727a.Coremail.cjian720@163.com>
1 sibling, 1 reply; 4+ messages in thread
From: Andrea Righi @ 2026-06-12 16:32 UTC (permalink / raw)
To: Cui Jian
Cc: tj, void, changwoo, mingo, peterz, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
kprateek.nayak, sched-ext, linux-kernel
Hi Cui,
On Sat, Jun 13, 2026 at 12:14:03AM +0800, Cui Jian wrote:
> 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.
The preempt reason is only used in ops.cpu_release(), which is a deprecated API
and will be removed in the next kernel versions (see the pr_warn() in
validate_ops(), kernel/sched/ext.c):
pr_warn("ops->cpu_acquire/release() are deprecated, use sched_switch TP instead\n");
So, your patch makes sense, but I'm not sure it's worth updating the API at this
point.
Thanks,
-Andrea
>
> 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 [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-12 18:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-12 16:14 [PATCH] sched_ext:SCX is preemptible by the Fair scheduler Cui Jian
2026-06-12 16:28 ` sashiko-bot
2026-06-12 16:32 ` Andrea Righi
[not found] ` <4a81ba55.9be4.19ebce4727a.Coremail.cjian720@163.com>
2026-06-12 18:18 ` Andrea Righi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox