scx_lavd: make a loop easier to correctly verify

With an ill combination of old kernel and old LLVM, the BPF verifier
incorrectly detects an infinite loop. After changing the loop with a
constant end, the old verifier can pass the code.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
This commit is contained in:
Changwoo Min 2024-08-27 17:06:48 +09:00
parent 09cff560aa
commit 00430c3ded

View File

@ -2053,10 +2053,13 @@ static bool consume_task(s32 cpu, struct cpu_ctx *cpuc, u64 now)
continue;
nuance = bpf_get_prandom_u32();
for (int j = 0; j < nr_nbr; j++) {
for (int j = 0; j < LAVD_CPDOM_MAX_NR; j++, nuance = dsq_id + 1) {
if (j >= nr_nbr)
break;
dsq_id = pick_any_bit(cpdomc->neighbor_bits[i], nuance);
if (dsq_id == -ENOENT)
goto next_neighbor;
continue;
cpdomc_pick = MEMBER_VPTR(cpdom_ctxs, [dsq_id]);
if (!cpdomc_pick) {
@ -2065,12 +2068,10 @@ static bool consume_task(s32 cpu, struct cpu_ctx *cpuc, u64 now)
}
if (!cpdomc_pick->is_active)
goto next_neighbor;
continue;
if (consume_dsq(cpu, dsq_id, now))
return true;
next_neighbor:
nuance = dsq_id + 1;
}
}