Skip to content

Commit ce2b93f

Browse files
committed
sched_ext: Fix dsq_local_on selftest
The dsp_local_on selftest expects the scheduler to fail by trying to schedule an e.g. CPU-affine task to the wrong CPU. However, this isn't guaranteed to happen in the 1 second window that the test is running. Besides, it's odd to have this particular exception path tested when there are no other tests that verify that the interface is working at all - e.g. the test would pass if dsp_local_on interface is completely broken and fails on any attempt. Flip the test so that it verifies that the feature works. While at it, fix a typo in the info message. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Ihor Solodrai <ihor.solodrai@pm.me> Link: http://lkml.kernel.org/r/Z1n9v7Z6iNJ-wKmq@slm.duckdns.org Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 35bf430 commit ce2b93f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

tools/testing/selftests/sched_ext/dsp_local_on.bpf.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ void BPF_STRUCT_OPS(dsp_local_on_dispatch, s32 cpu, struct task_struct *prev)
4343
if (!p)
4444
return;
4545

46-
target = bpf_get_prandom_u32() % nr_cpus;
46+
if (p->nr_cpus_allowed == nr_cpus)
47+
target = bpf_get_prandom_u32() % nr_cpus;
48+
else
49+
target = scx_bpf_task_cpu(p);
4750

4851
scx_bpf_dsq_insert(p, SCX_DSQ_LOCAL_ON | target, SCX_SLICE_DFL, 0);
4952
bpf_task_release(p);

tools/testing/selftests/sched_ext/dsp_local_on.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ static enum scx_test_status run(void *ctx)
3434
/* Just sleeping is fine, plenty of scheduling events happening */
3535
sleep(1);
3636

37-
SCX_EQ(skel->data->uei.kind, EXIT_KIND(SCX_EXIT_ERROR));
3837
bpf_link__destroy(link);
3938

39+
SCX_EQ(skel->data->uei.kind, EXIT_KIND(SCX_EXIT_UNREG));
40+
4041
return SCX_TEST_PASS;
4142
}
4243

@@ -50,7 +51,7 @@ static void cleanup(void *ctx)
5051
struct scx_test dsp_local_on = {
5152
.name = "dsp_local_on",
5253
.description = "Verify we can directly dispatch tasks to a local DSQs "
53-
"from osp.dispatch()",
54+
"from ops.dispatch()",
5455
.setup = setup,
5556
.run = run,
5657
.cleanup = cleanup,

0 commit comments

Comments
 (0)