Skip to content

Commit ea38803

Browse files
committed
scx_lavd: Switch to scx_bpf_remote_curr()
The new scx_bpf_remote_curr() is safer to use, switch to it from scx_bpf_cpu_rq() as we only care about it's ->curr anyway. Signed-off-by: Christian Loehle <[email protected]>
1 parent da738e0 commit ea38803

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

scheds/rust/scx_lavd/src/bpf/preempt.bpf.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,10 @@ static void ask_cpu_yield_after(struct cpu_ctx *victim_cpuc, u64 new_slice)
189189
* set the victim task's time slice to zero so the victim task yields
190190
* the CPU in the next scheduling point.
191191
*/
192-
struct rq *victim_rq;
193192
struct task_struct *victim_p;
194193

195-
victim_rq = scx_bpf_cpu_rq(victim_cpuc->cpu_id);
196-
if (victim_rq && (victim_p = victim_rq->curr)) {
194+
victim_p = scx_bpf_remote_curr(victim_cpuc->cpu_id);
195+
if (victim_p) {
197196
/*
198197
* Finding a victim is racy, but we do not coordinate. Thus,
199198
* two different CPUs can choose the same victim CPU. We do not
@@ -213,8 +212,10 @@ static void ask_cpu_yield_after(struct cpu_ctx *victim_cpuc, u64 new_slice)
213212
* (SCX_SLICE_DFL, 20 msec).
214213
*/
215214
u64 old = victim_cpuc->est_stopping_clk;
216-
if (!old)
215+
if (!old) {
216+
bpf_task_release(victim_p);
217217
return;
218+
}
218219

219220
/*
220221
* If the new slice is one, this is the last time to be kicked,
@@ -232,6 +233,7 @@ static void ask_cpu_yield_after(struct cpu_ctx *victim_cpuc, u64 new_slice)
232233
if (victim_p->scx.slice > new_slice)
233234
WRITE_ONCE(victim_p->scx.slice, new_slice);
234235
}
236+
bpf_task_release(victim_p);
235237
}
236238
}
237239

0 commit comments

Comments
 (0)