Commit 45d0278
committed
scx_flow: fix autotuner ratio and target_cpu validation
Address two remaining issues from Copilot review PR sched-ext#3525:
1. main.rs: Fix direct_mismatch_ratio denominator
The original code used cpu_biases as the denominator, but
direct_local_mismatches can increment even when no bias was
applied (when no stability bias was available). This could
cause inflated ratios and incorrect autotuner decisions.
Now uses cpu_biases.saturating_add(direct_mismatches) as
the denominator to properly represent all attempts.
2. main.bpf.c: Add target_cpu >= 0 guard
scx_bpf_task_cpu(p) can return -1 in test scenarios.
Passing a negative CPU to bpf_cpumask_test_cpu() or using
SCX_DSQ_LOCAL_ON | target_cpu is undefined behavior.
Now validates target_cpu before cpumask operations.
Fixes: sched-ext#3525 (comment)
Fixes: sched-ext#3525 (comment)1 parent 7c0311a commit 45d0278
2 files changed
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1362 | 1362 | | |
1363 | 1363 | | |
1364 | 1364 | | |
1365 | | - | |
| 1365 | + | |
| 1366 | + | |
1366 | 1367 | | |
1367 | 1368 | | |
1368 | 1369 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
481 | 481 | | |
482 | 482 | | |
483 | 483 | | |
484 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
485 | 487 | | |
486 | 488 | | |
487 | 489 | | |
| |||
0 commit comments