Re: Re: [PATCH bpf-next 0/2] sched_ext: Mark scx_bpf_cpu_rq() nullable

From: Nuoqi Gui

Date: Fri Jun 19 2026 - 12:08:33 EST





> -----Original Messages-----
> From: "Christian Loehle" <christian.loehle@xxxxxxx>
> Send time:Friday, 19/06/2026 23:31:59
> To: "Nuoqi Gui" <gnq25@xxxxxxxxxxxxxxxxxxxxx>, "Tejun Heo" <tj@xxxxxxxxxx>, "David Vernet" <void@xxxxxxxxxxxxx>, "Alexei Starovoitov" <ast@xxxxxxxxxx>, "Daniel Borkmann" <daniel@xxxxxxxxxxxxx>, "Andrii Nakryiko" <andrii@xxxxxxxxxx>
> Cc: "Andrea Righi" <arighi@xxxxxxxxxx>, "Changwoo Min" <changwoo@xxxxxxxxxx>, "Shuah Khan" <shuah@xxxxxxxxxx>, sched-ext@xxxxxxxxxxxxxxx, bpf@xxxxxxxxxxxxxxx, linux-kselftest@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH bpf-next 0/2] sched_ext: Mark scx_bpf_cpu_rq() nullable
>
> On 6/19/26 15:45, Nuoqi Gui wrote:
> > scx_bpf_cpu_rq() can return NULL for invalid CPU input or when no SCX
> > scheduler is active, but its kfunc registration does not advertise the
> > nullable return to the verifier.
> >
> > Add KF_RET_NULL to scx_bpf_cpu_rq(), matching the nullable metadata already
> > present on neighboring SCX accessors, and add a sched_ext selftest that rejects
> > an unchecked direct runqueue field read.
> >
>
> See 5c48d88fe004 ("sched_ext: deprecation warn for scx_bpf_cpu_rq()")
> I guess I can send a patch to remove the function, it's been a while.
>
> > This fixes a regression introduced by 6203ef73fa5c ("sched/ext: Add BPF
> > function to fetch rq").
>
> How so?
>
> >
> > Signed-off-by: Nuoqi Gui <gnq25@xxxxxxxxxxxxxxxxxxxxx>
> > ---
> > Nuoqi Gui (2):
> > sched_ext: Mark scx_bpf_cpu_rq() as nullable
> > selftests/sched_ext: Cover scx_bpf_cpu_rq() null return
> >
> > kernel/sched/ext.c | 2 +-
> > tools/testing/selftests/sched_ext/Makefile | 1 +
> > .../selftests/sched_ext/cpu_rq_ret_null.bpf.c | 27 +++++++++++++++
> > .../testing/selftests/sched_ext/cpu_rq_ret_null.c | 38 ++++++++++++++++++++++
> > 4 files changed, 67 insertions(+), 1 deletion(-)
> > ---
> > base-commit: e4287bf34f97a88c7d9322f5bde828724c073a6b
> > change-id: 20260617-f01-14-scx-cpu-rq-ret-null-2e79535acd57
> >
> > Best regards,
> > --
> > Nuoqi Gui <gnq25@xxxxxxxxxxxxxxxxxxxxx>
> >
> >

Thanks, you're right. "Regression" was inaccurate; the missing KF_RET_NULL
metadata has been there since the kfunc was introduced by 6203ef73fa5c.

If the preferred direction is to remove scx_bpf_cpu_rq(), I'll drop this
series.