Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+37 -29
+2
MAINTAINERS
··· 20907 20907 SCHEDULER - SCHED_EXT 20908 20908 R: Tejun Heo <tj@kernel.org> 20909 20909 R: David Vernet <void@manifault.com> 20910 + R: Andrea Righi <arighi@nvidia.com> 20911 + R: Changwoo Min <changwoo@igalia.com> 20910 20912 L: linux-kernel@vger.kernel.org 20911 20913 S: Maintained 20912 20914 W: https://github.com/sched-ext/scx
+2 -2
kernel/sched/ext.c
··· 4763 4763 * sees scx_rq_bypassing() before moving tasks to SCX. 4764 4764 */ 4765 4765 if (!scx_enabled()) { 4766 - rq_unlock_irqrestore(rq, &rf); 4766 + rq_unlock(rq, &rf); 4767 4767 continue; 4768 4768 } 4769 4769 ··· 7013 7013 return -ENOENT; 7014 7014 7015 7015 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; 7017 7017 kit->cursor.priv = READ_ONCE(kit->dsq->seq); 7018 7018 7019 7019 return 0;
+3 -3
tools/sched_ext/include/scx/common.bpf.h
··· 40 40 void scx_bpf_dsq_insert_vtime(struct task_struct *p, u64 dsq_id, u64 slice, u64 vtime, u64 enq_flags) __ksym __weak; 41 41 u32 scx_bpf_dispatch_nr_slots(void) __ksym; 42 42 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; 46 46 bool scx_bpf_dsq_move(struct bpf_iter_scx_dsq *it__iter, struct task_struct *p, u64 dsq_id, u64 enq_flags) __ksym __weak; 47 47 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; 48 48 u32 scx_bpf_reenqueue_local(void) __ksym;
+1 -1
tools/sched_ext/scx_central.c
··· 97 97 SCX_BUG_ON(!cpuset, "Failed to allocate cpuset"); 98 98 CPU_ZERO(cpuset); 99 99 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), 101 101 "Failed to affinitize to central CPU %d (max %d)", 102 102 skel->rodata->central_cpu, skel->rodata->nr_cpu_ids - 1); 103 103 CPU_FREE(cpuset);
+1 -1
tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.bpf.c
··· 20 20 * If we dispatch to a bogus DSQ that will fall back to the 21 21 * builtin global DSQ, we fail gracefully. 22 22 */ 23 - scx_bpf_dispatch_vtime(p, 0xcafef00d, SCX_SLICE_DFL, 23 + scx_bpf_dsq_insert_vtime(p, 0xcafef00d, SCX_SLICE_DFL, 24 24 p->scx.dsq_vtime, 0); 25 25 return cpu; 26 26 }
+2 -2
tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.bpf.c
··· 17 17 18 18 if (cpu >= 0) { 19 19 /* 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); 22 22 return cpu; 23 23 } 24 24
+5 -2
tools/testing/selftests/sched_ext/dsp_local_on.bpf.c
··· 43 43 if (!p) 44 44 return; 45 45 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); 47 50 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); 49 52 bpf_task_release(p); 50 53 } 51 54
+3 -2
tools/testing/selftests/sched_ext/dsp_local_on.c
··· 34 34 /* Just sleeping is fine, plenty of scheduling events happening */ 35 35 sleep(1); 36 36 37 - SCX_EQ(skel->data->uei.kind, EXIT_KIND(SCX_EXIT_ERROR)); 38 37 bpf_link__destroy(link); 38 + 39 + SCX_EQ(skel->data->uei.kind, EXIT_KIND(SCX_EXIT_UNREG)); 39 40 40 41 return SCX_TEST_PASS; 41 42 } ··· 51 50 struct scx_test dsp_local_on = { 52 51 .name = "dsp_local_on", 53 52 .description = "Verify we can directly dispatch tasks to a local DSQs " 54 - "from osp.dispatch()", 53 + "from ops.dispatch()", 55 54 .setup = setup, 56 55 .run = run, 57 56 .cleanup = cleanup,
+1 -1
tools/testing/selftests/sched_ext/enq_select_cpu_fails.bpf.c
··· 31 31 /* Can only call from ops.select_cpu() */ 32 32 scx_bpf_select_cpu_dfl(p, 0, 0, &found); 33 33 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); 35 35 } 36 36 37 37 SEC(".struct_ops.link")
+2 -2
tools/testing/selftests/sched_ext/exit.bpf.c
··· 33 33 if (exit_point == EXIT_ENQUEUE) 34 34 EXIT_CLEANLY(); 35 35 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); 37 37 } 38 38 39 39 void BPF_STRUCT_OPS(exit_dispatch, s32 cpu, struct task_struct *p) ··· 41 41 if (exit_point == EXIT_DISPATCH) 42 42 EXIT_CLEANLY(); 43 43 44 - scx_bpf_consume(DSQ_ID); 44 + scx_bpf_dsq_move_to_local(DSQ_ID); 45 45 } 46 46 47 47 void BPF_STRUCT_OPS(exit_enable, struct task_struct *p)
+5 -3
tools/testing/selftests/sched_ext/maximal.bpf.c
··· 12 12 13 13 char _license[] SEC("license") = "GPL"; 14 14 15 + #define DSQ_ID 0 16 + 15 17 s32 BPF_STRUCT_OPS(maximal_select_cpu, struct task_struct *p, s32 prev_cpu, 16 18 u64 wake_flags) 17 19 { ··· 22 20 23 21 void BPF_STRUCT_OPS(maximal_enqueue, struct task_struct *p, u64 enq_flags) 24 22 { 25 - scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); 23 + scx_bpf_dsq_insert(p, DSQ_ID, SCX_SLICE_DFL, enq_flags); 26 24 } 27 25 28 26 void BPF_STRUCT_OPS(maximal_dequeue, struct task_struct *p, u64 deq_flags) ··· 30 28 31 29 void BPF_STRUCT_OPS(maximal_dispatch, s32 cpu, struct task_struct *prev) 32 30 { 33 - scx_bpf_consume(SCX_DSQ_GLOBAL); 31 + scx_bpf_dsq_move_to_local(DSQ_ID); 34 32 } 35 33 36 34 void BPF_STRUCT_OPS(maximal_runnable, struct task_struct *p, u64 enq_flags) ··· 125 123 126 124 s32 BPF_STRUCT_OPS_SLEEPABLE(maximal_init) 127 125 { 128 - return 0; 126 + return scx_bpf_create_dsq(DSQ_ID, -1); 129 127 } 130 128 131 129 void BPF_STRUCT_OPS(maximal_exit, struct scx_exit_info *info)
+1 -1
tools/testing/selftests/sched_ext/select_cpu_dfl.bpf.c
··· 30 30 } 31 31 scx_bpf_put_idle_cpumask(idle_mask); 32 32 33 - scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); 33 + scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); 34 34 } 35 35 36 36 SEC(".struct_ops.link")
+1 -1
tools/testing/selftests/sched_ext/select_cpu_dfl_nodispatch.bpf.c
··· 67 67 saw_local = true; 68 68 } 69 69 70 - scx_bpf_dispatch(p, dsq_id, SCX_SLICE_DFL, enq_flags); 70 + scx_bpf_dsq_insert(p, dsq_id, SCX_SLICE_DFL, enq_flags); 71 71 } 72 72 73 73 s32 BPF_STRUCT_OPS(select_cpu_dfl_nodispatch_init_task,
+1 -1
tools/testing/selftests/sched_ext/select_cpu_dispatch.bpf.c
··· 29 29 cpu = prev_cpu; 30 30 31 31 dispatch: 32 - scx_bpf_dispatch(p, dsq_id, SCX_SLICE_DFL, 0); 32 + scx_bpf_dsq_insert(p, dsq_id, SCX_SLICE_DFL, 0); 33 33 return cpu; 34 34 } 35 35
+1 -1
tools/testing/selftests/sched_ext/select_cpu_dispatch_bad_dsq.bpf.c
··· 18 18 s32 prev_cpu, u64 wake_flags) 19 19 { 20 20 /* Dispatching to a random DSQ should fail. */ 21 - scx_bpf_dispatch(p, 0xcafef00d, SCX_SLICE_DFL, 0); 21 + scx_bpf_dsq_insert(p, 0xcafef00d, SCX_SLICE_DFL, 0); 22 22 23 23 return prev_cpu; 24 24 }
+2 -2
tools/testing/selftests/sched_ext/select_cpu_dispatch_dbl_dsp.bpf.c
··· 18 18 s32 prev_cpu, u64 wake_flags) 19 19 { 20 20 /* Dispatching twice in a row is disallowed. */ 21 - scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, 0); 22 - scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, 0); 21 + scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, 0); 22 + scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, 0); 23 23 24 24 return prev_cpu; 25 25 }
+4 -4
tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c
··· 2 2 /* 3 3 * A scheduler that validates that enqueue flags are properly stored and 4 4 * applied at dispatch time when a task is directly dispatched from 5 - * ops.select_cpu(). We validate this by using scx_bpf_dispatch_vtime(), and 6 - * making the test a very basic vtime scheduler. 5 + * ops.select_cpu(). We validate this by using scx_bpf_dsq_insert_vtime(), 6 + * and making the test a very basic vtime scheduler. 7 7 * 8 8 * Copyright (c) 2024 Meta Platforms, Inc. and affiliates. 9 9 * Copyright (c) 2024 David Vernet <dvernet@meta.com> ··· 47 47 cpu = prev_cpu; 48 48 scx_bpf_test_and_clear_cpu_idle(cpu); 49 49 ddsp: 50 - scx_bpf_dispatch_vtime(p, VTIME_DSQ, SCX_SLICE_DFL, task_vtime(p), 0); 50 + scx_bpf_dsq_insert_vtime(p, VTIME_DSQ, SCX_SLICE_DFL, task_vtime(p), 0); 51 51 return cpu; 52 52 } 53 53 54 54 void BPF_STRUCT_OPS(select_cpu_vtime_dispatch, s32 cpu, struct task_struct *p) 55 55 { 56 - if (scx_bpf_consume(VTIME_DSQ)) 56 + if (scx_bpf_dsq_move_to_local(VTIME_DSQ)) 57 57 consumed = true; 58 58 } 59 59