aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / evidence / timer_window_starvation_2026-10-19 / README.md
| 1 | # M1 timer window starvation (aienos#434 gate AIENOS-CK-QEMU-GATES, rc_nonzero), 2026-10-19 |
| 2 | |
| 3 | ## Symptom |
| 4 | Judge run of aienos#434 head 49e6f6a: `AIENOS-CK-QEMU-GATES` FAIL rc_nonzero. The failing child was the |
| 5 | Allen gate (`[allen] exit 1`), whose M1 checks (`scripts/lib_ck_m1_checks.sh`) rejected the timer window: |
| 6 | "timer IRQ delivered fewer than five ticks" or "tick statistics out of range". The same head passes |
| 7 | when the Spark is quiet (5/5 `qemu_ck_allen_test.sh` runs PASS), so the code under test was not at fault. |
| 8 | |
| 9 | ## Cause |
| 10 | `ck_timer_window` is wall-clock (200 ms). QEMU TCG shares the Spark with the whole hive (load 20 to 67). |
| 11 | A starved vCPU runs fewer than five 10 ms ticks inside the 200 ms window, and `ck_timer_tick` read the |
| 12 | counter a second time after re-arming, so a host stall between the two reads made one interval long and the |
| 13 | next one short (min_us as low as 9 against a 10000 us period). |
| 14 | |
| 15 | ## Fix (native/kernel/arch/timer.c, scripts/ck_gates.sh) |
| 16 | 1. An interval runs from IRQ entry to IRQ entry, the same counter value the next deadline is built from, so |
| 17 | it is never shorter than the period. |
| 18 | 2. The window keeps counting, up to 5 s, until five ticks have arrived. A dead timer still reports 0 ticks. |
| 19 | 3. A failing child's own FAIL lines are now copied into the gate's evidence blob (the child log lives in a |
| 20 | temp folder that is removed at exit, which is why the first failure could not be read afterwards). |
| 21 | |
| 22 | ## Measurement (Spark, 20 boots of `scripts/qemu_ck_boot_test.sh` per arm, pinned to CPU 3 with 5 busy loops |
| 23 | on the same CPU at the same nice level; `pinned-stress.sh`) |
| 24 | | arm | pass | fail | |
| 25 | |---|---|---| |
| 26 | | before the fix (origin/main 18e2765) | 2 | 18 | |
| 27 | | after the fix (fix/timer-window-starvation) | 20 | 0 | |
| 28 | |
| 29 | Red: `red-before-fix-fails.txt`, `red-before-fix-stats.txt`. Green: `green-after-fix-stats.txt`. |
| 30 | Quiet machine, 5 runs of the Allen gate before the fix: 5/5 PASS (so the fix changes nothing when idle). |
| 31 | Also run after the fix: `scripts/ck_gates.sh --self-test` PASS, `make -C native/kernel test` PASS (CK_CORE_HOST). |