| cc07fae1 | 30-Sep-2026 |
Kuba Piecuch <jpiecuch@google.com> |
selftests/sched_ext: Add a test for ops.dequeue() on remote local DSQ moves
Add a dequeue_remote test that makes moves of tasks in the BPF scheduler's custody to another CPU's local DSQ the common c
selftests/sched_ext: Add a test for ops.dequeue() on remote local DSQ moves
Add a dequeue_remote test that makes moves of tasks in the BPF scheduler's custody to another CPU's local DSQ the common case, both via SCX_DSQ_LOCAL_ON dispatch and via scx_bpf_dsq_move_to_local(). The BPF scheduler tracks each task's custody state and triggers scx_bpf_error() if a custody period doesn't end with exactly one ops.dequeue() before the task runs, or if it ends with an SCX_DEQ_CORE_SCHED_EXEC dequeue of a task without a core cookie.
Without the previous patch, the test fails with:
sched_ext: dequeue_remote: dequeue_remote.bpf.c:141: 15 (rcu_preempt): late ops.dequeue() with SCX_DEQ_CORE_SCHED_EXEC (enq_cpu=3 cpu=2 seq=1) ... ops_dequeue+0x114/0x170 set_next_task_scx+0x104/0x1e0 __pick_next_task+0xc7/0x180 __schedule+0x154/0x1870
Reviewed-by: Andrea Righi <arighi@nvidia.com> Assisted-by: Claude:claude-opus-5.5 Signed-off-by: Kuba Piecuch <jpiecuch@google.com> Signed-off-by: Tejun Heo <tj@kernel.org>
show more ...
|
| d781d1b7 | 19-Sep-2026 |
Tejun Heo <tj@kernel.org> |
selftests/sched_ext: Check the cmask cid-form ops.enable() receives
cid-form ops.enable() now hands the task's cmask to the scheduler and set_cmask() repeats it right after. Add a cid-form selftest
selftests/sched_ext: Check the cmask cid-form ops.enable() receives
cid-form ops.enable() now hands the task's cmask to the scheduler and set_cmask() repeats it right after. Add a cid-form selftest that checks both against p->cpus_ptr, that they match each other, that the initial set_cmask() lands before set_weight() and before the task first becomes runnable, and that set_cmask() never precedes enable(), across class-switch enables, fork-path enables and live affinity changes.
v2: Mismatch details returned through a caller-local struct instead of globals, alloc_words validated in the header check, loop bounded by nr_cids directly (Andrea Righi).
Signed-off-by: Tejun Heo <tj@kernel.org>
show more ...
|
| e72979d3 | 11-Aug-2026 |
Michal Blaszczyk <michalblk@google.com> |
selftests/sched_ext: Fix flaky ddsp failure tests on busy systems
The ddsp_vtimelocal_fail and ddsp_bogus_dsq_fail tests skip calling scx_bpf_dsq_insert_vtime() if scx_bpf_pick_idle_cpu() fails to f
selftests/sched_ext: Fix flaky ddsp failure tests on busy systems
The ddsp_vtimelocal_fail and ddsp_bogus_dsq_fail tests skip calling scx_bpf_dsq_insert_vtime() if scx_bpf_pick_idle_cpu() fails to find an idle CPU (returns a negative error code). On loaded systems, this results in the tests skipping the very assertions they are meant to verify.
Eliminate this flakiness by falling back to prev_cpu if no idle CPU is found, ensuring the illegal dispatch operations are unconditionally attempted and tested.
Fixes: a5db7817af78 ("sched_ext: Add selftests") Signed-off-by: Michal Blaszczyk <michalblk@google.com> Signed-off-by: Tejun Heo <tj@kernel.org>
show more ...
|
| 0e3a6e97 | 11-Aug-2026 |
Cheng-Yang Chou <yphbchou0911@gmail.com> |
selftests/sched_ext: Make numa idle validation race-free
A CPU returned by scx_bpf_pick_idle_cpu_node() can be re-advertised as idle by an idle-to-idle re-pick before the BPF program validates the s
selftests/sched_ext: Make numa idle validation race-free
A CPU returned by scx_bpf_pick_idle_cpu_node() can be re-advertised as idle by an idle-to-idle re-pick before the BPF program validates the selection, and the scx_bpf_pick_any_cpu_node() fallback doesn't claim the CPU at all. Asserting that the picked CPU is absent from the node's idle cpumask is therefore inherently racy.
Follow the same approach as commit 12da4723b679 ("selftests/sched_ext: Make allowed_cpus idle validation race-free") and validate a stable local invariant instead: a CPU executing ops.select_cpu() in a non-idle scheduling context must not be advertised as idle in its node's idle cpumask. Keep the node-membership validation of the picked CPU, which is stable.
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
show more ...
|
| 4dc310b4 | 07-Aug-2026 |
Liang Luo <luoliang@kylinos.cn> |
selftests/sched_ext: Check skeleton open failure in exit test
exit.c does not check the return value of exit__open(). If it returns NULL, which happens when the skeleton wrapper fails to allocate th
selftests/sched_ext: Check skeleton open failure in exit test
exit.c does not check the return value of exit__open(). If it returns NULL, which happens when the skeleton wrapper fails to allocate the object or open the BPF ELF, the very next line dereferences it via SCX_ENUM_INIT(). That macro expands to SCX_ENUM_SET(), which accesses skel->rodata, causing a NULL pointer dereference.
Every other selftest guards this with SCX_FAIL_IF(!skel, ...); exit.c is the only one missing it.
Fixes: a5db7817af78 ("sched_ext: Add selftests") Signed-off-by: Liang Luo <luoliang@kylinos.cn> Signed-off-by: Tejun Heo <tj@kernel.org>
show more ...
|
| d4a00d61 | 23-Jul-2026 |
Kuba Piecuch <jpiecuch@google.com> |
selftests/sched_ext: Handle sleeping task affinity changes in numa test
When a sleeping task's affinity is changed, task_cpu(p) can be outside of p->cpus_ptr until after select_task_rq() selects a n
selftests/sched_ext: Handle sleeping task affinity changes in numa test
When a sleeping task's affinity is changed, task_cpu(p) can be outside of p->cpus_ptr until after select_task_rq() selects a new runqueue for the task during wakeup.
Thus, the task's NUMA node determined by numa_select_cpu() can be completely outside of the task's cpumask, leading to scx_pick_{idle,any}_cpu_node() failing to find an eligible CPU and returning -EBUSY. This leads to the numa.bpf.c scheduler abnormally exiting with the following message in dmesg:
sched_ext: numa: invalid CPU -16 scx_bpf_cpu_node+0x120/0x190 bpf_prog_0a34b8e0f515771f_numa_select_cpu+0x108/0x14e bpf__sched_ext_ops_select_cpu+0x4f/0xb4 select_task_rq_scx+0xb0/0x210 select_task_rq+0xa0/0xd0 __try_to_wake_up+0x196/0x650 complete_all+0x76/0x100 migration_cpu_stop+0x22b/0x300 cpu_stopper_thread+0xc1/0x180 smpboot_thread_fn+0x16b/0x230 kthread+0x2d7/0x350 ret_from_fork+0x1c2/0x350 ret_from_fork_asm+0x1a/0x30
Make numa_select_cpu() robust against this case by returning @prev_cpu if no CPU could be found in the selected NUMA node _and_ we have reason to believe that the task's affinity was changed while it was sleeping.
Fixes: 5ae5161820e5 ("selftests/sched_ext: Add NUMA-aware scheduler test") Signed-off-by: Kuba Piecuch <jpiecuch@google.com> Signed-off-by: Tejun Heo <tj@kernel.org>
show more ...
|
| ad45691d | 09-Jul-2026 |
Tejun Heo <tj@kernel.org> |
Merge branch 'for-7.2-fixes' into for-7.3
Pull to receive:
db4e9defd2e8 ("sched_ext: Record an error on errno-only sub-enable failure") 49b3378a750c ("sched_ext: Fix premature ops->priv publicati
Merge branch 'for-7.2-fixes' into for-7.3
Pull to receive:
db4e9defd2e8 ("sched_ext: Record an error on errno-only sub-enable failure") 49b3378a750c ("sched_ext: Fix premature ops->priv publication in scx_alloc_and_add_sched()") e6979d05c6a6 ("tools/sched_ext: scx - Fix cmask_subset(), cmask_equal() and cmask_weight()")
for further sub-sched changes and to resolve the conflicts with the sub-sched updates on for-7.3.
db4e9defd2e8 adds scx_error() to the sub-enable err_disable sink which for-7.3 moved from ext.c into sub.c. Resolved by applying the fix to scx_sub_enable_workfn() in sub.c.
49b3378a750c drops RCU_INIT_POINTER() from an scx_alloc_and_add_sched() unwind label whose body changed with for-7.3's stall_cpus addition. Resolved by dropping the line from the updated unwind.
Signed-off-by: Tejun Heo <tj@kernel.org>
show more ...
|
| 3788e325 | 10-May-2026 |
Andrea Righi <arighi@nvidia.com> |
selftests/sched_ext: Fix build error in dequeue selftest
Building the dequeue selftest with newer compilers (e.g., gcc 16) triggers the following error:
dequeue.c:28:22: error: variable 'sum' set
selftests/sched_ext: Fix build error in dequeue selftest
Building the dequeue selftest with newer compilers (e.g., gcc 16) triggers the following error:
dequeue.c:28:22: error: variable 'sum' set but not used
The 'volatile' qualifier prevents the writes from being optimized away, but does not silence the unused variable 'sum' is indeed only written and never read.
Consume 'sum' via an empty asm() with a register input constraint. This forces the compiler to keep the accumulated value (preserving the CPU stress loop) and avoiding the build error.
Fixes: 658ad2259b3e ("selftests/sched_ext: Add test to validate ops.dequeue() semantics") Signed-off-by: Andrea Righi <arighi@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org>
show more ...
|
| e18002d2 | 08-May-2026 |
Cheng-Yang Chou <yphbchou0911@gmail.com> |
selftests/sched_ext: Fix select_cpu_dfl link leak on early return
If run() exits early via SCX_EQ/SCX_ASSERT (which calls return directly), bpf_link__destroy() is never reached and the BPF scheduler
selftests/sched_ext: Fix select_cpu_dfl link leak on early return
If run() exits early via SCX_EQ/SCX_ASSERT (which calls return directly), bpf_link__destroy() is never reached and the BPF scheduler stays loaded. All subsequent tests then fail to attach because SCX is not in the DISABLED state.
Move bpf_link into a context struct so cleanup() always destroys it, regardless of how run() exits. Also skip waitpid() for children where fork() returned -1, avoiding waitpid(-1,...) accidentally reaping an unrelated child and triggering the early return path.
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: Andrea Righi <arighi@nvidia.com>
show more ...
|
| 8cd8b474 | 23-Apr-2026 |
Zhao Mengmeng <zhaomengmeng@kylinos.cn> |
selftests/sched_ext: Include common.bpf.h to avoid build failure
In scx-cid patchsets, sched_ext selftest failed to build with following error:
non_scx_kfunc_deny.bpf.c:17:6: error: conflicting typ
selftests/sched_ext: Include common.bpf.h to avoid build failure
In scx-cid patchsets, sched_ext selftest failed to build with following error:
non_scx_kfunc_deny.bpf.c:17:6: error: conflicting types for 'scx_bpf_kick_cpu' 17 | void scx_bpf_kick_cpu(s32 cpu, u64 flags) __ksym; | ^ tools/testing/selftests/sched_ext/build/include/vmlinux.h:136300:13: note: previous declaration is here 136300 | extern void scx_bpf_kick_cpu(s32 cpu, u64 flags, const struct bpf_prog_aux *aux) __weak __ksym; | ^ non_scx_kfunc_deny.bpf.c:26:23: error: too few arguments to function call, expected 3, have 2 26 | scx_bpf_kick_cpu(0, 0); | ~~~~~~~~~~~~~~~~ ^ tools/testing/selftests/sched_ext/build/include/vmlinux.h:136300:13: note: 'scx_bpf_kick_cpu' declared here 136300 | extern void scx_bpf_kick_cpu(s32 cpu, u64 flags, const struct bpf_prog_aux *aux) __weak __ksym;
The root cause is on scx core part, but we can avoid this by including common.bpf.h and remove scx_bpf_kick_cpu() to make it more robust, just like the usage in other xx.bpf.c.
Link: https://lore.kernel.org/sched-ext/20260421071945.3110084-1-tj@kernel.org/ Signed-off-by: Zhao Mengmeng <zhaomengmeng@kylinos.cn> Tested-by: Cheng-Yang Chou <yphbchou0911@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
show more ...
|
| dcd47f27 | 10-Apr-2026 |
fangqiurong <fangqiurong@kylinos.cn> |
selftests/sched_ext: Fix wrong DSQ ID in peek_dsq error message
The error path after scx_bpf_create_dsq(real_dsq_id, ...) was reporting test_dsq_id instead of real_dsq_id in the error message, which
selftests/sched_ext: Fix wrong DSQ ID in peek_dsq error message
The error path after scx_bpf_create_dsq(real_dsq_id, ...) was reporting test_dsq_id instead of real_dsq_id in the error message, which would mislead debugging.
Signed-off-by: fangqiurong <fangqiurong@kylinos.cn> Signed-off-by: Tejun Heo <tj@kernel.org>
show more ...
|
| ff1befcb | 08-Apr-2026 |
Cheng-Yang Chou <yphbchou0911@gmail.com> |
selftests/sched_ext: Improve runner error reporting for invalid arguments
Report an error for './runner foo' (positional arg instead of -t) and for './runner -t foo' when the filter matches no tests
selftests/sched_ext: Improve runner error reporting for invalid arguments
Report an error for './runner foo' (positional arg instead of -t) and for './runner -t foo' when the filter matches no tests. Previously both cases produced no error output.
Pre-scan the test list before the main loop so the error is reported immediately, avoiding spurious SKIP output from '-s' when no tests match.
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
show more ...
|
| 94555ca6 | 30-Mar-2026 |
Tejun Heo <tj@kernel.org> |
Merge branch 'for-7.0-fixes' into for-7.1
Conflict in kernel/sched/ext.c init_sched_ext_class() between:
415cb193bb97 ("sched_ext: Fix SCX_KICK_WAIT deadlock by deferring wait to balance callba
Merge branch 'for-7.0-fixes' into for-7.1
Conflict in kernel/sched/ext.c init_sched_ext_class() between:
415cb193bb97 ("sched_ext: Fix SCX_KICK_WAIT deadlock by deferring wait to balance callback")
which adds cpus_to_sync cpumask allocation, and:
84b1a0ea0b7c ("sched_ext: Implement scx_bpf_dsq_reenq() for user DSQs") 8c1b9453fde6 ("sched_ext: Convert deferred_reenq_locals from llist to regular list")
which add deferred_reenq init code at the same location. Both are independent additions. Include both.
Signed-off-by: Tejun Heo <tj@kernel.org>
show more ...
|
| 090d34f0 | 29-Mar-2026 |
Tejun Heo <tj@kernel.org> |
selftests/sched_ext: Add cyclic SCX_KICK_WAIT stress test
Add a test that creates a 3-CPU kick_wait cycle (A->B->C->A). A BPF scheduler kicks the next CPU in the ring with SCX_KICK_WAIT on every enq
selftests/sched_ext: Add cyclic SCX_KICK_WAIT stress test
Add a test that creates a 3-CPU kick_wait cycle (A->B->C->A). A BPF scheduler kicks the next CPU in the ring with SCX_KICK_WAIT on every enqueue while userspace workers generate continuous scheduling churn via sched_yield(). Without the preceding fix, this hangs the machine within seconds.
Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: Christian Loehle <christian.loehle@arm.com> Tested-by: Christian Loehle <christian.loehle@arm.com>
show more ...
|