|
| 1 | +From ef7009decc30eb2515a64253791d61b72229c119 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Ihor Solodrai <ihor.solodrai@pm.me> |
| 3 | +Date: Thu, 21 Nov 2024 21:40:17 +0000 |
| 4 | +Subject: [PATCH 1001/1008] selftests/sched_ext: fix build after renames in |
| 5 | + sched_ext API |
| 6 | + |
| 7 | +The selftests are falining to build on current tip of bpf-next and |
| 8 | +sched_ext [1]. This has broken BPF CI [2] after merge from upstream. |
| 9 | + |
| 10 | +Use appropriate function names in the selftests according to the |
| 11 | +recent changes in the sched_ext API [3]. |
| 12 | + |
| 13 | +[1] https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=fc39fb56917bb3cb53e99560ca3612a84456ada2 |
| 14 | +[2] https://github.com/kernel-patches/bpf/actions/runs/11959327258/job/33340923745 |
| 15 | +[3] https://lore.kernel.org/all/20241109194853.580310-1-tj@kernel.org/ |
| 16 | + |
| 17 | +Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me> |
| 18 | +Acked-by: Andrea Righi <arighi@nvidia.com> |
| 19 | +Acked-by: David Vernet <void@manifault.com> |
| 20 | +Signed-off-by: Tejun Heo <tj@kernel.org> |
| 21 | +--- |
| 22 | + .../testing/selftests/sched_ext/ddsp_bogus_dsq_fail.bpf.c | 2 +- |
| 23 | + .../selftests/sched_ext/ddsp_vtimelocal_fail.bpf.c | 4 ++-- |
| 24 | + tools/testing/selftests/sched_ext/dsp_local_on.bpf.c | 2 +- |
| 25 | + .../selftests/sched_ext/enq_select_cpu_fails.bpf.c | 2 +- |
| 26 | + tools/testing/selftests/sched_ext/exit.bpf.c | 4 ++-- |
| 27 | + tools/testing/selftests/sched_ext/maximal.bpf.c | 4 ++-- |
| 28 | + tools/testing/selftests/sched_ext/select_cpu_dfl.bpf.c | 2 +- |
| 29 | + .../selftests/sched_ext/select_cpu_dfl_nodispatch.bpf.c | 2 +- |
| 30 | + .../testing/selftests/sched_ext/select_cpu_dispatch.bpf.c | 2 +- |
| 31 | + .../selftests/sched_ext/select_cpu_dispatch_bad_dsq.bpf.c | 2 +- |
| 32 | + .../selftests/sched_ext/select_cpu_dispatch_dbl_dsp.bpf.c | 4 ++-- |
| 33 | + tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c | 8 ++++---- |
| 34 | + 12 files changed, 19 insertions(+), 19 deletions(-) |
| 35 | + |
| 36 | +diff --git a/tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.bpf.c b/tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.bpf.c |
| 37 | +index 37d9bf6fb745..6f4c3f5a1c5d 100644 |
| 38 | +--- a/tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.bpf.c |
| 39 | ++++ b/tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.bpf.c |
| 40 | +@@ -20,7 +20,7 @@ s32 BPF_STRUCT_OPS(ddsp_bogus_dsq_fail_select_cpu, struct task_struct *p, |
| 41 | + * If we dispatch to a bogus DSQ that will fall back to the |
| 42 | + * builtin global DSQ, we fail gracefully. |
| 43 | + */ |
| 44 | +- scx_bpf_dispatch_vtime(p, 0xcafef00d, SCX_SLICE_DFL, |
| 45 | ++ scx_bpf_dsq_insert_vtime(p, 0xcafef00d, SCX_SLICE_DFL, |
| 46 | + p->scx.dsq_vtime, 0); |
| 47 | + return cpu; |
| 48 | + } |
| 49 | +diff --git a/tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.bpf.c b/tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.bpf.c |
| 50 | +index dffc97d9cdf1..e4a55027778f 100644 |
| 51 | +--- a/tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.bpf.c |
| 52 | ++++ b/tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.bpf.c |
| 53 | +@@ -17,8 +17,8 @@ s32 BPF_STRUCT_OPS(ddsp_vtimelocal_fail_select_cpu, struct task_struct *p, |
| 54 | + |
| 55 | + if (cpu >= 0) { |
| 56 | + /* Shouldn't be allowed to vtime dispatch to a builtin DSQ. */ |
| 57 | +- scx_bpf_dispatch_vtime(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL, |
| 58 | +- p->scx.dsq_vtime, 0); |
| 59 | ++ scx_bpf_dsq_insert_vtime(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL, |
| 60 | ++ p->scx.dsq_vtime, 0); |
| 61 | + return cpu; |
| 62 | + } |
| 63 | + |
| 64 | +diff --git a/tools/testing/selftests/sched_ext/dsp_local_on.bpf.c b/tools/testing/selftests/sched_ext/dsp_local_on.bpf.c |
| 65 | +index 6a7db1502c29..6325bf76f47e 100644 |
| 66 | +--- a/tools/testing/selftests/sched_ext/dsp_local_on.bpf.c |
| 67 | ++++ b/tools/testing/selftests/sched_ext/dsp_local_on.bpf.c |
| 68 | +@@ -45,7 +45,7 @@ void BPF_STRUCT_OPS(dsp_local_on_dispatch, s32 cpu, struct task_struct *prev) |
| 69 | + |
| 70 | + target = bpf_get_prandom_u32() % nr_cpus; |
| 71 | + |
| 72 | +- scx_bpf_dispatch(p, SCX_DSQ_LOCAL_ON | target, SCX_SLICE_DFL, 0); |
| 73 | ++ scx_bpf_dsq_insert(p, SCX_DSQ_LOCAL_ON | target, SCX_SLICE_DFL, 0); |
| 74 | + bpf_task_release(p); |
| 75 | + } |
| 76 | + |
| 77 | +diff --git a/tools/testing/selftests/sched_ext/enq_select_cpu_fails.bpf.c b/tools/testing/selftests/sched_ext/enq_select_cpu_fails.bpf.c |
| 78 | +index 1efb50d61040..a7cf868d5e31 100644 |
| 79 | +--- a/tools/testing/selftests/sched_ext/enq_select_cpu_fails.bpf.c |
| 80 | ++++ b/tools/testing/selftests/sched_ext/enq_select_cpu_fails.bpf.c |
| 81 | +@@ -31,7 +31,7 @@ void BPF_STRUCT_OPS(enq_select_cpu_fails_enqueue, struct task_struct *p, |
| 82 | + /* Can only call from ops.select_cpu() */ |
| 83 | + scx_bpf_select_cpu_dfl(p, 0, 0, &found); |
| 84 | + |
| 85 | +- scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); |
| 86 | ++ scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); |
| 87 | + } |
| 88 | + |
| 89 | + SEC(".struct_ops.link") |
| 90 | +diff --git a/tools/testing/selftests/sched_ext/exit.bpf.c b/tools/testing/selftests/sched_ext/exit.bpf.c |
| 91 | +index d75d4faf07f6..4bc36182d3ff 100644 |
| 92 | +--- a/tools/testing/selftests/sched_ext/exit.bpf.c |
| 93 | ++++ b/tools/testing/selftests/sched_ext/exit.bpf.c |
| 94 | +@@ -33,7 +33,7 @@ void BPF_STRUCT_OPS(exit_enqueue, struct task_struct *p, u64 enq_flags) |
| 95 | + if (exit_point == EXIT_ENQUEUE) |
| 96 | + EXIT_CLEANLY(); |
| 97 | + |
| 98 | +- scx_bpf_dispatch(p, DSQ_ID, SCX_SLICE_DFL, enq_flags); |
| 99 | ++ scx_bpf_dsq_insert(p, DSQ_ID, SCX_SLICE_DFL, enq_flags); |
| 100 | + } |
| 101 | + |
| 102 | + void BPF_STRUCT_OPS(exit_dispatch, s32 cpu, struct task_struct *p) |
| 103 | +@@ -41,7 +41,7 @@ void BPF_STRUCT_OPS(exit_dispatch, s32 cpu, struct task_struct *p) |
| 104 | + if (exit_point == EXIT_DISPATCH) |
| 105 | + EXIT_CLEANLY(); |
| 106 | + |
| 107 | +- scx_bpf_consume(DSQ_ID); |
| 108 | ++ scx_bpf_dsq_move_to_local(DSQ_ID); |
| 109 | + } |
| 110 | + |
| 111 | + void BPF_STRUCT_OPS(exit_enable, struct task_struct *p) |
| 112 | +diff --git a/tools/testing/selftests/sched_ext/maximal.bpf.c b/tools/testing/selftests/sched_ext/maximal.bpf.c |
| 113 | +index 4d4cd8d966db..4c005fa71810 100644 |
| 114 | +--- a/tools/testing/selftests/sched_ext/maximal.bpf.c |
| 115 | ++++ b/tools/testing/selftests/sched_ext/maximal.bpf.c |
| 116 | +@@ -20,7 +20,7 @@ s32 BPF_STRUCT_OPS(maximal_select_cpu, struct task_struct *p, s32 prev_cpu, |
| 117 | + |
| 118 | + void BPF_STRUCT_OPS(maximal_enqueue, struct task_struct *p, u64 enq_flags) |
| 119 | + { |
| 120 | +- scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); |
| 121 | ++ scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); |
| 122 | + } |
| 123 | + |
| 124 | + void BPF_STRUCT_OPS(maximal_dequeue, struct task_struct *p, u64 deq_flags) |
| 125 | +@@ -28,7 +28,7 @@ void BPF_STRUCT_OPS(maximal_dequeue, struct task_struct *p, u64 deq_flags) |
| 126 | + |
| 127 | + void BPF_STRUCT_OPS(maximal_dispatch, s32 cpu, struct task_struct *prev) |
| 128 | + { |
| 129 | +- scx_bpf_consume(SCX_DSQ_GLOBAL); |
| 130 | ++ scx_bpf_dsq_move_to_local(SCX_DSQ_GLOBAL); |
| 131 | + } |
| 132 | + |
| 133 | + void BPF_STRUCT_OPS(maximal_runnable, struct task_struct *p, u64 enq_flags) |
| 134 | +diff --git a/tools/testing/selftests/sched_ext/select_cpu_dfl.bpf.c b/tools/testing/selftests/sched_ext/select_cpu_dfl.bpf.c |
| 135 | +index f171ac470970..13d0f5be788d 100644 |
| 136 | +--- a/tools/testing/selftests/sched_ext/select_cpu_dfl.bpf.c |
| 137 | ++++ b/tools/testing/selftests/sched_ext/select_cpu_dfl.bpf.c |
| 138 | +@@ -30,7 +30,7 @@ void BPF_STRUCT_OPS(select_cpu_dfl_enqueue, struct task_struct *p, |
| 139 | + } |
| 140 | + scx_bpf_put_idle_cpumask(idle_mask); |
| 141 | + |
| 142 | +- scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); |
| 143 | ++ scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); |
| 144 | + } |
| 145 | + |
| 146 | + SEC(".struct_ops.link") |
| 147 | +diff --git a/tools/testing/selftests/sched_ext/select_cpu_dfl_nodispatch.bpf.c b/tools/testing/selftests/sched_ext/select_cpu_dfl_nodispatch.bpf.c |
| 148 | +index 9efdbb7da928..815f1d5d61ac 100644 |
| 149 | +--- a/tools/testing/selftests/sched_ext/select_cpu_dfl_nodispatch.bpf.c |
| 150 | ++++ b/tools/testing/selftests/sched_ext/select_cpu_dfl_nodispatch.bpf.c |
| 151 | +@@ -67,7 +67,7 @@ void BPF_STRUCT_OPS(select_cpu_dfl_nodispatch_enqueue, struct task_struct *p, |
| 152 | + saw_local = true; |
| 153 | + } |
| 154 | + |
| 155 | +- scx_bpf_dispatch(p, dsq_id, SCX_SLICE_DFL, enq_flags); |
| 156 | ++ scx_bpf_dsq_insert(p, dsq_id, SCX_SLICE_DFL, enq_flags); |
| 157 | + } |
| 158 | + |
| 159 | + s32 BPF_STRUCT_OPS(select_cpu_dfl_nodispatch_init_task, |
| 160 | +diff --git a/tools/testing/selftests/sched_ext/select_cpu_dispatch.bpf.c b/tools/testing/selftests/sched_ext/select_cpu_dispatch.bpf.c |
| 161 | +index 59bfc4f36167..4bb99699e920 100644 |
| 162 | +--- a/tools/testing/selftests/sched_ext/select_cpu_dispatch.bpf.c |
| 163 | ++++ b/tools/testing/selftests/sched_ext/select_cpu_dispatch.bpf.c |
| 164 | +@@ -29,7 +29,7 @@ s32 BPF_STRUCT_OPS(select_cpu_dispatch_select_cpu, struct task_struct *p, |
| 165 | + cpu = prev_cpu; |
| 166 | + |
| 167 | + dispatch: |
| 168 | +- scx_bpf_dispatch(p, dsq_id, SCX_SLICE_DFL, 0); |
| 169 | ++ scx_bpf_dsq_insert(p, dsq_id, SCX_SLICE_DFL, 0); |
| 170 | + return cpu; |
| 171 | + } |
| 172 | + |
| 173 | +diff --git a/tools/testing/selftests/sched_ext/select_cpu_dispatch_bad_dsq.bpf.c b/tools/testing/selftests/sched_ext/select_cpu_dispatch_bad_dsq.bpf.c |
| 174 | +index 3bbd5fcdfb18..2a75de11b2cf 100644 |
| 175 | +--- a/tools/testing/selftests/sched_ext/select_cpu_dispatch_bad_dsq.bpf.c |
| 176 | ++++ b/tools/testing/selftests/sched_ext/select_cpu_dispatch_bad_dsq.bpf.c |
| 177 | +@@ -18,7 +18,7 @@ s32 BPF_STRUCT_OPS(select_cpu_dispatch_bad_dsq_select_cpu, struct task_struct *p |
| 178 | + s32 prev_cpu, u64 wake_flags) |
| 179 | + { |
| 180 | + /* Dispatching to a random DSQ should fail. */ |
| 181 | +- scx_bpf_dispatch(p, 0xcafef00d, SCX_SLICE_DFL, 0); |
| 182 | ++ scx_bpf_dsq_insert(p, 0xcafef00d, SCX_SLICE_DFL, 0); |
| 183 | + |
| 184 | + return prev_cpu; |
| 185 | + } |
| 186 | +diff --git a/tools/testing/selftests/sched_ext/select_cpu_dispatch_dbl_dsp.bpf.c b/tools/testing/selftests/sched_ext/select_cpu_dispatch_dbl_dsp.bpf.c |
| 187 | +index 0fda57fe0ecf..99d075695c97 100644 |
| 188 | +--- a/tools/testing/selftests/sched_ext/select_cpu_dispatch_dbl_dsp.bpf.c |
| 189 | ++++ b/tools/testing/selftests/sched_ext/select_cpu_dispatch_dbl_dsp.bpf.c |
| 190 | +@@ -18,8 +18,8 @@ s32 BPF_STRUCT_OPS(select_cpu_dispatch_dbl_dsp_select_cpu, struct task_struct *p |
| 191 | + s32 prev_cpu, u64 wake_flags) |
| 192 | + { |
| 193 | + /* Dispatching twice in a row is disallowed. */ |
| 194 | +- scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, 0); |
| 195 | +- scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, 0); |
| 196 | ++ scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, 0); |
| 197 | ++ scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, 0); |
| 198 | + |
| 199 | + return prev_cpu; |
| 200 | + } |
| 201 | +diff --git a/tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c b/tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c |
| 202 | +index e6c67bcf5e6e..bfcb96cd4954 100644 |
| 203 | +--- a/tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c |
| 204 | ++++ b/tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c |
| 205 | +@@ -2,8 +2,8 @@ |
| 206 | + /* |
| 207 | + * A scheduler that validates that enqueue flags are properly stored and |
| 208 | + * applied at dispatch time when a task is directly dispatched from |
| 209 | +- * ops.select_cpu(). We validate this by using scx_bpf_dispatch_vtime(), and |
| 210 | +- * making the test a very basic vtime scheduler. |
| 211 | ++ * ops.select_cpu(). We validate this by using scx_bpf_dsq_insert_vtime(), |
| 212 | ++ * and making the test a very basic vtime scheduler. |
| 213 | + * |
| 214 | + * Copyright (c) 2024 Meta Platforms, Inc. and affiliates. |
| 215 | + * Copyright (c) 2024 David Vernet <dvernet@meta.com> |
| 216 | +@@ -47,13 +47,13 @@ s32 BPF_STRUCT_OPS(select_cpu_vtime_select_cpu, struct task_struct *p, |
| 217 | + cpu = prev_cpu; |
| 218 | + scx_bpf_test_and_clear_cpu_idle(cpu); |
| 219 | + ddsp: |
| 220 | +- scx_bpf_dispatch_vtime(p, VTIME_DSQ, SCX_SLICE_DFL, task_vtime(p), 0); |
| 221 | ++ scx_bpf_dsq_insert_vtime(p, VTIME_DSQ, SCX_SLICE_DFL, task_vtime(p), 0); |
| 222 | + return cpu; |
| 223 | + } |
| 224 | + |
| 225 | + void BPF_STRUCT_OPS(select_cpu_vtime_dispatch, s32 cpu, struct task_struct *p) |
| 226 | + { |
| 227 | +- if (scx_bpf_consume(VTIME_DSQ)) |
| 228 | ++ if (scx_bpf_dsq_move_to_local(VTIME_DSQ)) |
| 229 | + consumed = true; |
| 230 | + } |
| 231 | + |
| 232 | +-- |
| 233 | +2.47.1 |
| 234 | + |
0 commit comments