Re: [PATCH 1/2] compat.bpf.h: Gate scx_bpf_dsq_peek kfunc behind kernel version 7.1.0
From: Tejun Heo
Date: Mon Aug 17 2026 - 13:41:38 EST
Hello,
On Mon, Aug 17, 2026 at 11:31:25PM +0900, Changwoo Min wrote:
> __COMPAT_scx_bpf_dsq_peek() selects the lockless kfunc whenever the
> symbol resolves in the kernel BTF. However, its lockless implementation
> could return a stale task_struct pointer. The stale pointer issues are
> resolved only after v7.1 kernel with the following patches:
>
> commit 2f2ea7709266 ("sched_ext: Use dsq->first_task instead of list_empty() in dispatch_enqueue() FIFO-tail")
> commit 71d7847cad44 ("sched_ext: Fix scx_bpf_dsq_peek() with FIFO DSQs")
71d7847cad44 shipped in v6.19 together with the peek API itself, so every
mainline release that has the kfunc already has it. Only 2f2ea7709266 is
new in v7.1, and what it fixes on v6.19/v7.0 is scx_bpf_dsq_peek()
spuriously returning NULL on a non-empty FIFO DSQ, not stale pointers.
The gate itself looks fine but can you update the description and the
comment so that they describe what the gate is actually avoiding?
> + * The kfunc exists on earlier kernels but its lockless implementation could
> + * return stale task pointers. Require kernel version >= 7.1.0 before calling
> + * it; otherwise fall through to the bpf_iter_scx_dsq fallback below.
> + *
> */
Also, the edit leaves a dangling " *" line before the closing "*/".
Thanks.
--
tejun