# G21 code review → G23 (2026-08-02)

The review that produced G23, its findings and their dispositions, and the
resume state. Companion to STATE.md `§` registry §G23 (registration) and STATE.md
(current status). Review scope: G21 commits `a8770e46d..1951def97`, gaming
performance lens.

## Findings and dispositions

| # | Severity | Finding | Disposition |
|---|---|---|---|
| F1 | HIGH | 4× fair-share detector needs ≥25% of total IRQ volume — only the loudest sink can flag; G22 found three, USB (CPU 5) worst for `Window & Input` | **FIXED** `05209e24f` — per-line rule (≥1 kHz, ≥95% one CPU) |
| F2 | MEDIUM | dfl-then-swap abandons the idle claim dfl made on the sink (kernel test-and-clears what it returns; repairs only on next idle re-pick). RT-dodge leak class | **FIXED** `1c6b97559` — swap deleted; `scx_bpf_select_cpu_and` claim is always the CPU used |
| F3 | MEDIUM | `/proc/interrupts` columns mapped by position — offline CPUs (SMT off) flag the WRONG CPU | **FIXED** `05209e24f` — header `CPU<n>` labels |
| F4 | LOW | swap target used `pick_idle(flags=0)` — no idle-core ranking, could pick an unflagged sink | **FIXED** `1c6b97559` — kernel ranking via select_cpu_and, sinks masked |
| F5 | NOTE | rodata freeze folds nothing here (dynamic index ⇒ real load either way), so writable BSS + periodic re-probe costs zero extra hot-path cycles | **PARKED** — needs BPF-side mask rebuild machinery; own experiment |

## Facts verified during the review (kernel + live host)

- `scx_bpf_select_cpu_dfl` **claims** the idle CPU it returns:
  `scx_idle_test_and_clear_cpu` at kernel `ext/idle.c:534/572/620/632`. The
  bit is re-set only by `__scx_update_idle` (idle.c:749) on an idle
  transition or idle-to-idle re-pick (idle.c:759-771). An abandoned claim on
  a sink self-heals in ms (its own >1 kHz stream raises need_resched events)
  but the window is real.
- `scx_bpf_select_cpu_and` is on the running kernel (BTF-verified), ANDs the
  caller mask with `p->cpus_ptr` internally (idle.c:461-482, -EBUSY on empty
  intersection), and shares the R.6 WAKE_SYNC wart — the distrust block must
  stay.
- Live probe replication (desktop load): CPU 13 at 5.04× fair share
  (flaggable by the old rule), CPU 5 at 1.16× (mathematically unflaggable
  while nvidia dominates volume). Per-line rule flags both.
- Divide budget: **11**, not the documented 9 — A/B'd pre/post G23 at 11 → 11,
  identical distribution (dispatch 1, enqueue 2, enqueue_wake 2,
  frame_observe 1, handoff_yields 1, select_cpu 3, wake_vtime 1). The stale
  "9" predates G23; project CLAUDE.md corrected.

## G23 status at session end (2026-08-02)

**Code complete, smoke PASSED, endpoint UNMEASURED.** Commits:
`25ff596be` (registration) → `05209e24f` (detector) → `1c6b97559` (BPF) →
`77e6404d3` (DESIGN.md). Zero spills/fills every function;
`cake_select_cpu` 292 → 346 insns, `cake_init` 69 → 118 (attach-only).

**Smoke (live attach, 20 s, this desktop):** verifier accepted; probe logged
`46: xhci_hcd pins CPU 5 at 2158/s`, `115: nvidia pins CPU 13 at 15183/s`,
`interrupt-sink CPUs [5, 13]`; zero stalls; clean detach. **P1 CONFIRMED.**

## To resume the measurement

1. Receipts are BOOT-BOUND. This boot: A arm (pre-G23) =
   `target/cake_receipt_builds/20260802T085043Z_G21-irq-sink-avoidance_*`,
   B arm (G23) = `.../20260802T190731Z_head-77e6404d3770-ensure_*`. After any
   reboot: `bash cakebench artifact ensure` at HEAD for B, and rebuild A at
   commit `1951def97`.
2. Game id is `helldivers` (`config/game_benchmark_registry.json`,
   capture prefixes `helldivers2,main`). `game plan` without receipt targets
   returns `blocked_plan: awaits strict v2-manifest/v5-receipt activation` —
   that is the strict runner guard, not a fault; `game_ab` resolves receipts
   through its own transaction.
3. Endpoint per §G23: HD2 interleaved ABBA during ACTIVE play (P2 needs live
   mouse input — an unattended menu leaves the USB sink dormant), score mean
   wake for `Window & Input` / `main` / `renderer`, screen severe-frame
   ratio. Then the P4 throughput screen (`native-pair --workload
   perf-sched-pipe`, blocked while a game is up — `active_game_detected` is
   correct behavior).
4. Kill conditions and predictions P1-P4: STATE.md `§` registry §G23. P1 already
   confirmed at smoke.
