* [PATCH sched_ext/for-7.4] sched_ext: Work around pahole 1.32 dropping scx_bpf_task_set_lazy_resched() from BTF
@ 2026-09-29 17:32 Tejun Heo
2026-09-29 19:19 ` Andrea Righi
2026-09-29 23:11 ` Tejun Heo
0 siblings, 2 replies; 5+ messages in thread
From: Tejun Heo @ 2026-09-29 17:32 UTC (permalink / raw)
To: David Vernet, Andrea Righi, Changwoo Min
Cc: Emil Tsalapatis, David Dai, Yonghong Song, Alexei Starovoitov,
bpf, sched-ext, linux-kernel
With clang and pahole 1.32, x86-64 vmlinux BTF lacks
scx_bpf_task_set_lazy_resched() and sched_ext fails to initialize:
sched_ext: Failed to register kfunc sets (-22)
clang describes the lazy argument only after the prologue moves it into a
callee-saved register, which pahole 1.32 rejects as not being the argument
register. Released pahole is affected whatever the eventual fix. Keep the
argument on the stack with barrier_data() so that its location names no
register. OPTIMIZER_HIDE_VAR() would fix x86-64 but break arm64.
Fixes: f8e5a4e3f3be ("sched_ext: Add lazy preemption support")
Link: https://lore.kernel.org/r/20260925213619.2187751-1-yonghong.song@linux.dev
Signed-off-by: Tejun Heo <tj@kernel.org>
---
kernel/sched/ext/ext.c | 5 +++++
1 file changed, 5 insertions(+)
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -10136,6 +10136,11 @@ __bpf_kfunc bool scx_bpf_task_set_lazy_r
{
struct scx_sched *sch;
+ /*
+ * clang's register locations for @lazy make pahole 1.32 drop this kfunc
+ * from BTF. Keep @lazy in memory so its location names no register.
+ */
+ barrier_data(&lazy);
guard(rcu)();
sch = scx_prog_sched(aux);
if (unlikely(!sch || !scx_task_on_sched(sch, p)))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH sched_ext/for-7.4] sched_ext: Work around pahole 1.32 dropping scx_bpf_task_set_lazy_resched() from BTF
2026-09-29 17:32 [PATCH sched_ext/for-7.4] sched_ext: Work around pahole 1.32 dropping scx_bpf_task_set_lazy_resched() from BTF Tejun Heo
@ 2026-09-29 19:19 ` Andrea Righi
2026-09-29 19:25 ` Tejun Heo
2026-09-29 23:11 ` Tejun Heo
1 sibling, 1 reply; 5+ messages in thread
From: Andrea Righi @ 2026-09-29 19:19 UTC (permalink / raw)
To: Tejun Heo
Cc: David Vernet, Changwoo Min, Emil Tsalapatis, David Dai,
Yonghong Song, Alexei Starovoitov, bpf, sched-ext, linux-kernel
Hi Tejun,
On Tue, Sep 29, 2026 at 07:32:26AM -1000, Tejun Heo wrote:
> With clang and pahole 1.32, x86-64 vmlinux BTF lacks
> scx_bpf_task_set_lazy_resched() and sched_ext fails to initialize:
>
> sched_ext: Failed to register kfunc sets (-22)
>
> clang describes the lazy argument only after the prologue moves it into a
> callee-saved register, which pahole 1.32 rejects as not being the argument
> register. Released pahole is affected whatever the eventual fix. Keep the
> argument on the stack with barrier_data() so that its location names no
> register. OPTIMIZER_HIDE_VAR() would fix x86-64 but break arm64.
>
> Fixes: f8e5a4e3f3be ("sched_ext: Add lazy preemption support")
> Link: https://lore.kernel.org/r/20260925213619.2187751-1-yonghong.song@linux.dev
> Signed-off-by: Tejun Heo <tj@kernel.org>
> ---
> kernel/sched/ext/ext.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -10136,6 +10136,11 @@ __bpf_kfunc bool scx_bpf_task_set_lazy_r
> {
> struct scx_sched *sch;
>
> + /*
> + * clang's register locations for @lazy make pahole 1.32 drop this kfunc
> + * from BTF. Keep @lazy in memory so its location names no register.
> + */
> + barrier_data(&lazy);
First of all thanks for figuring this out, it was really annoying, I've been
holding pahole to 1.31 because of this.
I also looked a bit and it seems to be triggered specifically by the bool type.
This is with clang 22.1.8 on x86_64 without barrier_data and only changing the
type:
bool movl %esi, %ebp -> dropped by pahole
u32 movl %esi, %ebp -> ok
u64 movq %rsi, %r15 -> ok
With u32 the generated code is identical to the bool case, but clang keeps the
RSI entry range, so pahole is happy.
Should we just change lazy to u32 (or use a u64 flags) instead of using
barrier_data()?
Thanks,
-Andrea
> guard(rcu)();
> sch = scx_prog_sched(aux);
> if (unlikely(!sch || !scx_task_on_sched(sch, p)))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH sched_ext/for-7.4] sched_ext: Work around pahole 1.32 dropping scx_bpf_task_set_lazy_resched() from BTF
2026-09-29 19:19 ` Andrea Righi
@ 2026-09-29 19:25 ` Tejun Heo
2026-09-29 19:37 ` Andrea Righi
0 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2026-09-29 19:25 UTC (permalink / raw)
To: Andrea Righi
Cc: David Vernet, Changwoo Min, Emil Tsalapatis, David Dai,
Yonghong Song, Alexei Starovoitov, bpf, sched-ext, linux-kernel
On Tue, Sep 29, 2026 at 09:19:50PM +0200, Andrea Righi wrote:
> First of all thanks for figuring this out, it was really annoying, I've been
> holding pahole to 1.31 because of this.
>
> I also looked a bit and it seems to be triggered specifically by the bool type.
> This is with clang 22.1.8 on x86_64 without barrier_data and only changing the
> type:
>
> bool movl %esi, %ebp -> dropped by pahole
> u32 movl %esi, %ebp -> ok
> u64 movq %rsi, %r15 -> ok
>
> With u32 the generated code is identical to the bool case, but clang keeps the
> RSI entry range, so pahole is happy.
>
> Should we just change lazy to u32 (or use a u64 flags) instead of using
> barrier_data()?
I mean, bool is the right and I'm hoping clang can be fixed and the
workaround seems to work, so keep it as-is unless there are other reasons to
change it (e.g. this becomes a wider interface taking u64 flags or sth like
that)?
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH sched_ext/for-7.4] sched_ext: Work around pahole 1.32 dropping scx_bpf_task_set_lazy_resched() from BTF
2026-09-29 19:25 ` Tejun Heo
@ 2026-09-29 19:37 ` Andrea Righi
0 siblings, 0 replies; 5+ messages in thread
From: Andrea Righi @ 2026-09-29 19:37 UTC (permalink / raw)
To: Tejun Heo
Cc: David Vernet, Changwoo Min, Emil Tsalapatis, David Dai,
Yonghong Song, Alexei Starovoitov, bpf, sched-ext, linux-kernel
On Tue, Sep 29, 2026 at 09:25:02AM -1000, Tejun Heo wrote:
> On Tue, Sep 29, 2026 at 09:19:50PM +0200, Andrea Righi wrote:
> > First of all thanks for figuring this out, it was really annoying, I've been
> > holding pahole to 1.31 because of this.
> >
> > I also looked a bit and it seems to be triggered specifically by the bool type.
> > This is with clang 22.1.8 on x86_64 without barrier_data and only changing the
> > type:
> >
> > bool movl %esi, %ebp -> dropped by pahole
> > u32 movl %esi, %ebp -> ok
> > u64 movq %rsi, %r15 -> ok
> >
> > With u32 the generated code is identical to the bool case, but clang keeps the
> > RSI entry range, so pahole is happy.
> >
> > Should we just change lazy to u32 (or use a u64 flags) instead of using
> > barrier_data()?
>
> I mean, bool is the right and I'm hoping clang can be fixed and the
> workaround seems to work, so keep it as-is unless there are other reasons to
> change it (e.g. this becomes a wider interface taking u64 flags or sth like
> that)?
Yeah, at the moment I don't see any valid reason to change lazy to a u64 flags.
And it's probably better to introduce a workaround in the code rather than a
workaround in the ABI, so let's keep barrier_data().
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Thanks,
-Andrea
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH sched_ext/for-7.4] sched_ext: Work around pahole 1.32 dropping scx_bpf_task_set_lazy_resched() from BTF
2026-09-29 17:32 [PATCH sched_ext/for-7.4] sched_ext: Work around pahole 1.32 dropping scx_bpf_task_set_lazy_resched() from BTF Tejun Heo
2026-09-29 19:19 ` Andrea Righi
@ 2026-09-29 23:11 ` Tejun Heo
1 sibling, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2026-09-29 23:11 UTC (permalink / raw)
To: David Vernet, Andrea Righi, Changwoo Min
Cc: Emil Tsalapatis, David Dai, Yonghong Song, Alexei Starovoitov,
bpf, sched-ext, linux-kernel
Applied to sched_ext/for-7.4.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-29 23:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-29 17:32 [PATCH sched_ext/for-7.4] sched_ext: Work around pahole 1.32 dropping scx_bpf_task_set_lazy_resched() from BTF Tejun Heo
2026-09-29 19:19 ` Andrea Righi
2026-09-29 19:25 ` Tejun Heo
2026-09-29 19:37 ` Andrea Righi
2026-09-29 23:11 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®