Skip to content

Commit 05c2e33

Browse files
committed
scx_layered: 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 ea38803 commit 05c2e33

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,6 @@ static bool try_preempt_cpu(s32 cand, struct task_struct *p, struct task_ctx *ta
12491249
struct layer *layer, u64 flags)
12501250
{
12511251
struct cpu_ctx *cpuc, *cand_cpuc, *sib_cpuc = NULL;
1252-
struct rq *rq;
12531252
struct task_struct *curr;
12541253
const struct cpumask *idle_cpumask;
12551254
bool cand_idle;
@@ -1276,19 +1275,20 @@ static bool try_preempt_cpu(s32 cand, struct task_struct *p, struct task_ctx *ta
12761275
if (scx_bpf_dsq_nr_queued(SCX_DSQ_LOCAL_ON | cand))
12771276
return false;
12781277

1279-
rq = scx_bpf_cpu_rq(cand);
1280-
if (!rq)
1278+
curr = scx_bpf_remote_curr(cand);
1279+
if (!curr)
12811280
return false;
1282-
curr = rq->curr;
12831281

12841282
if (ext_sched_class_addr && idle_sched_class_addr &&
12851283
((u64)curr->sched_class != ext_sched_class_addr) &&
12861284
((u64)curr->sched_class != idle_sched_class_addr)) {
1285+
bpf_task_release(curr);
12871286
if (!(cpuc = lookup_cpu_ctx(-1)))
12881287
return false;
12891288
gstat_inc(GSTAT_SKIP_PREEMPT, cpuc);
12901289
return false;
12911290
}
1291+
bpf_task_release(curr);
12921292

12931293
/*
12941294
* Don't preempt if protection against is in effect. However, open

0 commit comments

Comments
 (0)