Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Cheng-Yang Chou <yphbchou0911@gmail.com>
Cc: sched-ext@lists.linux.dev, Tejun Heo <tj@kernel.org>,
	David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>,
	Ching-Chun Huang <jserv@ccns.ncku.edu.tw>,
	Chia-Ping Tsai <chia7712@gmail.com>,
	chengyang.chou@mediatek.com, stable@vger.kernel.org,
	JaeJoon Jung <rgbi3307@gmail.com>
Subject: Re: [PATCH sched_ext/for-7.4-fixes] sched_ext: Don't request private stacks the JIT can't provide
Date: Tue, 24 Nov 2026 10:43:05 +0100	[thread overview]
Message-ID: <awVcKS_leVA8gmix@gpd4> (raw)
In-Reply-To: <20261123145450.12725-2-yphbchou0911@gmail.com>

Hi Cheng-Yang,

On Mon, Nov 23, 2026 at 10:54:51PM +0800, Cheng-Yang Chou wrote:
> Since commit 4f8b122848db ("sched_ext: Add basic building blocks for
> nested sub-scheduler dispatching"), bpf_scx_check_member() requests a
> private stack for ops.dispatch(), and later also for ops.sub_caps_updated(),
> whenever CONFIG_EXT_SUB_SCHED is set, which is the default.
> 
> The verifier fails the load with -EACCES if the JIT doesn't support
> private stacks, so on architectures whose JIT doesn't, like riscv64,
> no BPF scheduler that implements ops.dispatch() can be loaded.
> 
> The private stack is only needed when these operations nest, which only
> happens with sub-schedulers. Don't request it if the JIT can't provide
> it, and refuse to attach sub-schedulers in that case. Root schedulers
> then load as they did before sub-scheduler support was added.
> 
> Fixes: 4f8b122848db ("sched_ext: Add basic building blocks for nested sub-scheduler dispatching")
> Cc: stable@vger.kernel.org # v7.1+
> Reported-by: JaeJoon Jung <rgbi3307@gmail.com>
> Link: https://lore.kernel.org/all/20260810031418.95364-1-rgbi3307@gmail.com/
> Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>

Looks good to me.

Reviewed-by: Andrea Righi <arighi@nvidia.com>

Thanks,
-Andrea

> ---
> On riscv64 in QEMU (-M virt) running for-7.4-fixes,
> 
>   # echo 1 > /proc/sys/net/core/bpf_jit_enable
>   # ./scx_simple
> 
>   libbpf: prog 'simple_dispatch': BPF program load failed: -EACCES
>   libbpf: prog 'simple_dispatch': -- BEGIN PROG LOAD LOG --
>   Private stack not supported by jit
> 
> With it, scx_simple loads and runs.
> 
>  kernel/sched/ext/ext.c | 3 +++
>  kernel/sched/ext/sub.c | 6 ++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index 10de6bd865e8..3248ed57c2bb 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -9294,6 +9294,9 @@ static int bpf_scx_check_member(const struct btf_type *t,
>  	 * sub-scheds and sub-scheds themselves but I don't know how to access
>  	 * struct_ops from here.
>  	 */
> +	if (!bpf_jit_supports_private_stack())
> +		return 0;
> +
>  	switch (moff) {
>  	case offsetof(struct sched_ext_ops, dispatch):
>  		prog->aux->priv_stack_requested = true;
> diff --git a/kernel/sched/ext/sub.c b/kernel/sched/ext/sub.c
> index d2a20114eaa2..7c069a289766 100644
> --- a/kernel/sched/ext/sub.c
> +++ b/kernel/sched/ext/sub.c
> @@ -2246,6 +2246,12 @@ void scx_sub_enable_workfn(struct kthread_work *work)
>  		goto out_unlock;
>  	}
>  
> +	/* nesting ops need private stacks, see bpf_scx_check_member() */
> +	if (!bpf_jit_supports_private_stack()) {
> +		ret = -EOPNOTSUPP;
> +		goto out_unlock;
> +	}
> +
>  	cgrp = cgroup_get_from_id(ops->sub_cgroup_id);
>  	if (IS_ERR(cgrp)) {
>  		ret = PTR_ERR(cgrp);
> -- 
> 2.56.0
> 
> 

      reply	other threads:[~2026-11-24  9:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 14:54 [PATCH sched_ext/for-7.4-fixes] sched_ext: Don't request private stacks the JIT can't provide Cheng-Yang Chou
2026-11-24  9:43 ` Andrea Righi [this message]

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=awVcKS_leVA8gmix@gpd4 \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=chengyang.chou@mediatek.com \
    --cc=chia7712@gmail.com \
    --cc=jserv@ccns.ncku.edu.tw \
    --cc=rgbi3307@gmail.com \
    --cc=sched-ext@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    --cc=yphbchou0911@gmail.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