Sched_ext development
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Cui Jian <cjian720@163.com>
Cc: tj@kernel.org, void@manifault.com, changwoo@igalia.com,
	mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	vschneid@redhat.com, kprateek.nayak@amd.com,
	sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched_ext:SCX is preemptible by the Fair scheduler
Date: Fri, 12 Jun 2026 18:32:26 +0200	[thread overview]
Message-ID: <aiw0mo63sGsV-mnv@gpd4> (raw)
In-Reply-To: <20260612161403.105775-1-cjian720@163.com>

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
> 

  parent reply	other threads:[~2026-06-12 16:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
     [not found]   ` <4a81ba55.9be4.19ebce4727a.Coremail.cjian720@163.com>
2026-06-12 18:18     ` Andrea Righi
  -- strict thread matches above, loose matches on Subject: below --
2026-06-12 17:51 Cui Jian
2026-06-12 18:00 ` Andrea Righi
2026-06-12 18:05 ` sashiko-bot
2026-06-12 15:23 Cui Jian
2026-06-12 15:38 ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aiw0mo63sGsV-mnv@gpd4 \
    --to=arighi@nvidia.com \
    --cc=bsegall@google.com \
    --cc=changwoo@igalia.com \
    --cc=cjian720@163.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=void@manifault.com \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox