Skip to content

Commit 9de9b92

Browse files
committed
scx_tickless: Use scx_bpf_cpu_curr()
Use the new scx_bpf_cpu_curr() introduced in v6.18 as a safer way to access rq->curr instead of the deprecated scx_bpf_cpu_rq(). Signed-off-by: Christian Loehle <[email protected]>
1 parent 53b0556 commit 9de9b92

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scheds/rust/scx_tickless/src/bpf/main.bpf.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,14 +412,14 @@ static int sched_timerfn(void *map, int *key, struct bpf_timer *timer)
412412
/*
413413
* Check if we need to preempt the running tasks.
414414
*/
415+
bpf_rcu_read_lock();
415416
bpf_for(cpu, 0, nr_cpu_ids) {
416-
struct task_struct *p;
417+
struct task_struct *p = __COMPAT_scx_bpf_cpu_curr(cpu);
417418

418419
/*
419420
* Ignore CPU if idle task is running.
420421
*/
421-
p = scx_bpf_cpu_rq(cpu)->curr;
422-
if (p->flags & PF_IDLE)
422+
if (!p || p->flags & PF_IDLE)
423423
continue;
424424

425425
/*
@@ -438,6 +438,7 @@ static int sched_timerfn(void *map, int *key, struct bpf_timer *timer)
438438
__sync_fetch_and_add(&nr_preemptions, 1);
439439
}
440440
}
441+
bpf_rcu_read_unlock();
441442

442443
bpf_timer_start(timer, tick_interval_ns(), 0);
443444

0 commit comments

Comments
 (0)