Skip to content

Commit

Permalink
Merge pull request sched-ext#943 from JakeHillion/pr943
Browse files Browse the repository at this point in the history
replace goto with unrolled loop in antistall_set
  • Loading branch information
JakeHillion authored Nov 20, 2024
2 parents b4b1879 + c258199 commit 9bdccdd
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions scheds/rust/scx_layered/src/bpf/main.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2501,7 +2501,7 @@ u64 antistall_set(u64 dsq_id, u64 jiffies_now)
struct task_ctx *tctx;
s32 cpu;
u64 *antistall_dsq, *delay, cur_delay;
bool first_pass;
int pass;
u32 zero;

zero = 0;
Expand All @@ -2526,9 +2526,8 @@ u64 antistall_set(u64 dsq_id, u64 jiffies_now)
// check head task in dsq
goto unlock;

first_pass = true;
look_for_cpu:
bpf_for(cpu, 0, nr_possible_cpus) {
#pragma unroll
for (pass = 0; pass < 2; ++pass) bpf_for(cpu, 0, nr_possible_cpus) {
const struct cpumask *cpumask;

if (!(cpumask = cast_mask(tctx->layered_mask)))
Expand All @@ -2549,20 +2548,15 @@ u64 antistall_set(u64 dsq_id, u64 jiffies_now)
goto unlock;
}

if ((first_pass && *antistall_dsq == SCX_DSQ_INVALID) ||
(!first_pass && *delay < cur_delay)) {
if ((pass == 0 && *antistall_dsq == SCX_DSQ_INVALID) ||
(pass != 0 && *delay < cur_delay)) {
trace("antistall set DSQ[%llu] SELECTED_CPU[%llu] DELAY[%llu]", dsq_id, cpu, cur_delay);
*delay = cur_delay;
*antistall_dsq = dsq_id;
goto unlock;
}
}

if (first_pass) {
first_pass = false;
goto look_for_cpu;
}

goto unlock;
}

Expand Down

0 comments on commit 9bdccdd

Please sign in to comment.