Skip to content

Commit 63676ee

Browse files
committed
Merge tag 'sched_ext-for-6.13-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext
Pull sched_ext fixes from Tejun Heo: - Fix a bug where bpf_iter_scx_dsq_new() was not initializing the iterator's flags and could inadvertently enable e.g. reverse iteration - Fix a bug where scx_ops_bypass() could call irq_restore twice - Add Andrea and Changwoo as maintainers for better review coverage - selftests and tools/sched_ext build and other fixes * tag 'sched_ext-for-6.13-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext: sched_ext: Fix dsq_local_on selftest sched_ext: initialize kit->cursor.flags sched_ext: Fix invalid irq restore in scx_ops_bypass() MAINTAINERS: add me as reviewer for sched_ext MAINTAINERS: add self as reviewer for sched_ext scx: Fix maximal BPF selftest prog sched_ext: fix application of sizeof to pointer selftests/sched_ext: fix build after renames in sched_ext API sched_ext: Add __weak to fix the build errors
2 parents f9aa1fb + ce2b93f commit 63676ee

17 files changed

+37
-29
lines changed

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20907,6 +20907,8 @@ F: kernel/sched/
2090720907
SCHEDULER - SCHED_EXT
2090820908
R: Tejun Heo <tj@kernel.org>
2090920909
R: David Vernet <void@manifault.com>
20910+
R: Andrea Righi <arighi@nvidia.com>
20911+
R: Changwoo Min <changwoo@igalia.com>
2091020912
L: linux-kernel@vger.kernel.org
2091120913
S: Maintained
2091220914
W: https://github.com/sched-ext/scx

kernel/sched/ext.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4763,7 +4763,7 @@ static void scx_ops_bypass(bool bypass)
47634763
* sees scx_rq_bypassing() before moving tasks to SCX.
47644764
*/
47654765
if (!scx_enabled()) {
4766-
rq_unlock_irqrestore(rq, &rf);
4766+
rq_unlock(rq, &rf);
47674767
continue;
47684768
}
47694769

@@ -7013,7 +7013,7 @@ __bpf_kfunc int bpf_iter_scx_dsq_new(struct bpf_iter_scx_dsq *it, u64 dsq_id,
70137013
return -ENOENT;
70147014

70157015
INIT_LIST_HEAD(&kit->cursor.node);
7016-
kit->cursor.flags |= SCX_DSQ_LNODE_ITER_CURSOR | flags;
7016+
kit->cursor.flags = SCX_DSQ_LNODE_ITER_CURSOR | flags;
70177017
kit->cursor.priv = READ_ONCE(kit->dsq->seq);
70187018

70197019
return 0;

tools/sched_ext/include/scx/common.bpf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ void scx_bpf_dsq_insert(struct task_struct *p, u64 dsq_id, u64 slice, u64 enq_fl
4040
void scx_bpf_dsq_insert_vtime(struct task_struct *p, u64 dsq_id, u64 slice, u64 vtime, u64 enq_flags) __ksym __weak;
4141
u32 scx_bpf_dispatch_nr_slots(void) __ksym;
4242
void scx_bpf_dispatch_cancel(void) __ksym;
43-
bool scx_bpf_dsq_move_to_local(u64 dsq_id) __ksym;
44-
void scx_bpf_dsq_move_set_slice(struct bpf_iter_scx_dsq *it__iter, u64 slice) __ksym;
45-
void scx_bpf_dsq_move_set_vtime(struct bpf_iter_scx_dsq *it__iter, u64 vtime) __ksym;
43+
bool scx_bpf_dsq_move_to_local(u64 dsq_id) __ksym __weak;
44+
void scx_bpf_dsq_move_set_slice(struct bpf_iter_scx_dsq *it__iter, u64 slice) __ksym __weak;
45+
void scx_bpf_dsq_move_set_vtime(struct bpf_iter_scx_dsq *it__iter, u64 vtime) __ksym __weak;
4646
bool scx_bpf_dsq_move(struct bpf_iter_scx_dsq *it__iter, struct task_struct *p, u64 dsq_id, u64 enq_flags) __ksym __weak;
4747
bool scx_bpf_dsq_move_vtime(struct bpf_iter_scx_dsq *it__iter, struct task_struct *p, u64 dsq_id, u64 enq_flags) __ksym __weak;
4848
u32 scx_bpf_reenqueue_local(void) __ksym;

tools/sched_ext/scx_central.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
9797
SCX_BUG_ON(!cpuset, "Failed to allocate cpuset");
9898
CPU_ZERO(cpuset);
9999
CPU_SET(skel->rodata->central_cpu, cpuset);
100-
SCX_BUG_ON(sched_setaffinity(0, sizeof(cpuset), cpuset),
100+
SCX_BUG_ON(sched_setaffinity(0, sizeof(*cpuset), cpuset),
101101
"Failed to affinitize to central CPU %d (max %d)",
102102
skel->rodata->central_cpu, skel->rodata->nr_cpu_ids - 1);
103103
CPU_FREE(cpuset);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ s32 BPF_STRUCT_OPS(ddsp_bogus_dsq_fail_select_cpu, struct task_struct *p,
2020
* If we dispatch to a bogus DSQ that will fall back to the
2121
* builtin global DSQ, we fail gracefully.
2222
*/
23-
scx_bpf_dispatch_vtime(p, 0xcafef00d, SCX_SLICE_DFL,
23+
scx_bpf_dsq_insert_vtime(p, 0xcafef00d, SCX_SLICE_DFL,
2424
p->scx.dsq_vtime, 0);
2525
return cpu;
2626
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ s32 BPF_STRUCT_OPS(ddsp_vtimelocal_fail_select_cpu, struct task_struct *p,
1717

1818
if (cpu >= 0) {
1919
/* Shouldn't be allowed to vtime dispatch to a builtin DSQ. */
20-
scx_bpf_dispatch_vtime(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL,
21-
p->scx.dsq_vtime, 0);
20+
scx_bpf_dsq_insert_vtime(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL,
21+
p->scx.dsq_vtime, 0);
2222
return cpu;
2323
}
2424

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ 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

48-
scx_bpf_dispatch(p, SCX_DSQ_LOCAL_ON | target, SCX_SLICE_DFL, 0);
51+
scx_bpf_dsq_insert(p, SCX_DSQ_LOCAL_ON | target, SCX_SLICE_DFL, 0);
4952
bpf_task_release(p);
5053
}
5154

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,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void BPF_STRUCT_OPS(enq_select_cpu_fails_enqueue, struct task_struct *p,
3131
/* Can only call from ops.select_cpu() */
3232
scx_bpf_select_cpu_dfl(p, 0, 0, &found);
3333

34-
scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags);
34+
scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags);
3535
}
3636

3737
SEC(".struct_ops.link")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ void BPF_STRUCT_OPS(exit_enqueue, struct task_struct *p, u64 enq_flags)
3333
if (exit_point == EXIT_ENQUEUE)
3434
EXIT_CLEANLY();
3535

36-
scx_bpf_dispatch(p, DSQ_ID, SCX_SLICE_DFL, enq_flags);
36+
scx_bpf_dsq_insert(p, DSQ_ID, SCX_SLICE_DFL, enq_flags);
3737
}
3838

3939
void BPF_STRUCT_OPS(exit_dispatch, s32 cpu, struct task_struct *p)
4040
{
4141
if (exit_point == EXIT_DISPATCH)
4242
EXIT_CLEANLY();
4343

44-
scx_bpf_consume(DSQ_ID);
44+
scx_bpf_dsq_move_to_local(DSQ_ID);
4545
}
4646

4747
void BPF_STRUCT_OPS(exit_enable, struct task_struct *p)

0 commit comments

Comments
 (0)