Skip to content

compat.bpf.h: Add override for scx_bpf_dsq_peek version gate#3585

Open
bboymimi wants to merge 1 commit into
sched-ext:mainfrom
bboymimi:dsq-peek-override-knob
Open

compat.bpf.h: Add override for scx_bpf_dsq_peek version gate#3585
bboymimi wants to merge 1 commit into
sched-ext:mainfrom
bboymimi:dsq-peek-override-knob

Conversation

@bboymimi

Copy link
Copy Markdown
Contributor

a3f2784 ("compat.bpf.h: Gate scx_bpf_dsq_peek kfunc behind kernel
version 7.1.0") gates the lockless peek kfunc by LINUX_KERNEL_VERSION,
but the version check misses stable backports. A kernel that has both
upstream FIFO fixes

71d7847cad44 ("sched_ext: Fix scx_bpf_dsq_peek() with FIFO DSQs")
2f2ea7709266 ("sched_ext: Use dsq->first_task instead of list_empty()
in dispatch_enqueue() FIFO-tail")

cherry-picked but still reporting < 7.1.0 ends up on the iterator
fallback. CachyOS users on 6.18.31 reported a 4x FPS drop in Cyberpunk
2077.

Add __COMPAT_scx_allow_lockless_peek_unsafe as a __weak rodata bool.
When true, bpf_ksym_exists() alone is enough to take the fast path.
Expose it in scx_lavd as --allow-lockless-peek-unsafe. Default false,
so kernels without the fixes stay on the iterator path. Only enable
on kernels that have both fixes backported.

a3f2784 ("compat.bpf.h: Gate scx_bpf_dsq_peek kfunc behind kernel
version 7.1.0") gates the lockless peek kfunc by LINUX_KERNEL_VERSION,
but the version check misses stable backports. A kernel that has both
upstream FIFO fixes

  71d7847cad44 ("sched_ext: Fix scx_bpf_dsq_peek() with FIFO DSQs")
  2f2ea7709266 ("sched_ext: Use dsq->first_task instead of list_empty()
                  in dispatch_enqueue() FIFO-tail")

cherry-picked but still reporting < 7.1.0 ends up on the iterator
fallback. CachyOS users on 6.18.31 reported a 4x FPS drop in Cyberpunk
2077.

Add __COMPAT_scx_allow_lockless_peek_unsafe as a __weak rodata bool.
When true, bpf_ksym_exists() alone is enough to take the fast path.
Expose it in scx_lavd as --allow-lockless-peek-unsafe. Default false,
so kernels without the fixes stay on the iterator path. Only enable
on kernels that have both fixes backported.

Signed-off-by: Gavin Guo <gavinguo@igalia.com>
@daidavid

Copy link
Copy Markdown
Contributor

I'm not too convinced that using non-peek can cause this level of regression or else we'd have very poor performance for older kernels and/or older LAVD versions. Do we understand what causes the perf drop and can we replicate the regression in other microbenchmarks?

@multics69

Copy link
Copy Markdown
Contributor

Let's wait until we collect more evidence of the performance regression.

@ms178

ms178 commented May 19, 2026

Copy link
Copy Markdown

Thanks a lot for the patch which I've just tested with the latest scx-scheds-git main branch on Kernel 6.18.32 in these two scenarios:

Scenario A: LAVD without --allow-lockless-peek-unsafe --> this yielded the previously reported massive performance regression and massive stuttering

Possibly related dmesg output:

[19. Mai 10:07] NOHZ tick-stop error: local softirq work is pending, handler #80!!!
[  +0,000000] NOHZ tick-stop error: local softirq work is pending, handler #200!!!
[  +0,000554] NOHZ tick-stop error: local softirq work is pending, handler #200!!!

Scenario B: LAVD with --allow-lockless-peek-unsafe --> this brought back the expected performance level

@multics69

Copy link
Copy Markdown
Contributor

Thanks a lot for the patch which I've just tested with the latest scx-scheds-git main branch on Kernel 6.18.32 in these two scenarios:

Scenario A: LAVD without --allow-lockless-peek-unsafe --> this yielded the previously reported massive performance regression and massive stuttering

Possibly related dmesg output:

[19. Mai 10:07] NOHZ tick-stop error: local softirq work is pending, handler #80!!!
[  +0,000000] NOHZ tick-stop error: local softirq work is pending, handler #200!!!
[  +0,000554] NOHZ tick-stop error: local softirq work is pending, handler #200!!!

Scenario B: LAVD with --allow-lockless-peek-unsafe --> this brought back the expected performance level

What's the hardware you are using? It sounds like a pretty beefy machine with many CPUs?

@ms178

ms178 commented May 19, 2026

Copy link
Copy Markdown

What's the hardware you are using? It sounds like a pretty beefy machine with many CPUs?

@multics69 As mentioned in #3580 (comment), I use an Intel 14700KF (Raptor Lake) with a Z690 motherboard, 64 GB DDR4-3600, AMD Vega 64. The CPU comes with 8 P-Cores and 12 E-Cores.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants