Commit 01b0831
sched_ext: Fix SCX_KICK_WAIT to work reliably
commit a379fa1 upstream.
SCX_KICK_WAIT is used to synchronously wait for the target CPU to complete
a reschedule and can be used to implement operations like core scheduling.
This used to be implemented by scx_next_task_picked() incrementing pnt_seq,
which was always called when a CPU picks the next task to run, allowing
SCX_KICK_WAIT to reliably wait for the target CPU to enter the scheduler and
pick the next task.
However, commit b999e36 ("sched_ext: Replace scx_next_task_picked()
with switch_class()") replaced scx_next_task_picked() with the
switch_class() callback, which is only called when switching between sched
classes. This broke SCX_KICK_WAIT because pnt_seq would no longer be
reliably incremented unless the previous task was SCX and the next task was
not.
This fix leverages commit 4c95380 ("sched/ext: Fold balance_scx() into
pick_task_scx()") which refactored the pick path making put_prev_task_scx()
the natural place to track task switches for SCX_KICK_WAIT. The fix moves
pnt_seq increment to put_prev_task_scx() and also increments it in
pick_task_scx() to handle cases where the same task is re-selected, whether
by BPF scheduler decision or slice refill. The semantics: If the current
task on the target CPU is SCX, SCX_KICK_WAIT waits until the CPU enters the
scheduling path. This provides sufficient guarantee for use cases like core
scheduling while keeping the operation self-contained within SCX.
v2: - Also increment pnt_seq in pick_task_scx() to handle same-task
re-selection (Andrea Righi).
- Use smp_cond_load_acquire() for the busy-wait loop for better
architecture optimization (Peter Zijlstra).
Reported-by: Wen-Fang Liu <liuwenfang@honor.com>
Link: http://lkml.kernel.org/r/228ebd9e6ed3437996dffe15735a9caa@honor.com
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Christian Loehle <christian.loehle@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 664e78f commit 01b0831
2 files changed
Lines changed: 30 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2306 | 2306 | | |
2307 | 2307 | | |
2308 | 2308 | | |
2309 | | - | |
2310 | | - | |
2311 | | - | |
2312 | | - | |
2313 | | - | |
2314 | | - | |
2315 | 2309 | | |
2316 | 2310 | | |
2317 | 2311 | | |
| |||
2351 | 2345 | | |
2352 | 2346 | | |
2353 | 2347 | | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
2354 | 2352 | | |
2355 | 2353 | | |
2356 | 2354 | | |
| |||
2404 | 2402 | | |
2405 | 2403 | | |
2406 | 2404 | | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
2407 | 2408 | | |
2408 | 2409 | | |
2409 | 2410 | | |
| |||
5186 | 5187 | | |
5187 | 5188 | | |
5188 | 5189 | | |
5189 | | - | |
5190 | | - | |
| 5190 | + | |
| 5191 | + | |
| 5192 | + | |
| 5193 | + | |
| 5194 | + | |
| 5195 | + | |
5191 | 5196 | | |
5192 | 5197 | | |
5193 | 5198 | | |
| |||
5248 | 5253 | | |
5249 | 5254 | | |
5250 | 5255 | | |
5251 | | - | |
5252 | | - | |
5253 | | - | |
5254 | | - | |
5255 | | - | |
5256 | | - | |
5257 | | - | |
5258 | | - | |
5259 | | - | |
5260 | | - | |
5261 | | - | |
5262 | | - | |
| 5256 | + | |
| 5257 | + | |
| 5258 | + | |
| 5259 | + | |
| 5260 | + | |
| 5261 | + | |
| 5262 | + | |
| 5263 | + | |
| 5264 | + | |
| 5265 | + | |
| 5266 | + | |
| 5267 | + | |
| 5268 | + | |
5263 | 5269 | | |
5264 | 5270 | | |
5265 | 5271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
986 | 986 | | |
987 | 987 | | |
988 | 988 | | |
989 | | - | |
990 | | - | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
991 | 993 | | |
992 | 994 | | |
993 | 995 | | |
| |||
0 commit comments