LD_PRELOAD ioctl recorder, replay_diff.py, capture_stock.sh, replay_live.sh, golden stock 620.73.04 transcript + known-gaps, and an offline control test. Stock swap is opt-in via NV_RS_CAPTURE_BDF. No HANDOFF.md/AGENTS.md changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3.4 KiB
Replay testing against the stock driver
Real ioctl transcripts of the stock NVIDIA 620.73.04 open modules, recorded on the RTX 4060 Laptop
(AD107), compared with what nvidia_rs does for the same workloads. Three layers:
| Layer | Needs hardware | Command | Catches |
|---|---|---|---|
| Offline table check | no | cd src/nvidia && cargo test --test stock_capture_controls |
a control the stock driver serves that our tables lack or size differently |
| Live replay gate | yes (nvidia_rs loaded) | sh tools/ioctl_capture/replay_live.sh |
any new divergence from the stock transcript: status, missing or extra steps |
| Re-record | yes, swaps drivers | tools/ioctl_capture/capture_stock.sh swap / run / restore |
refreshes captures/stock/ and the golden after a driver or firmware bump |
Files
tools/ioctl_capture/nv_ioctl_capture.c:LD_PRELOADshim; records each/dev/nvidia*ioctl (top struct before/after, and the RM_CONTROL/RM_ALLOC parameter buffer) as JSONL. It only reads memory. Nested pointers inside parameter buffers are not followed.tools/ioctl_capture/capture_stock.sh:swap(nvidia_rs → stock modules),run NAME -- CMD(record intocaptures/NAME.jsonl),restore(stock → nvidia_rs throughdev_reload.sh).CAPTURE_SUDO=sudois needed against nvidia_rs when dev mode makes the nodes root-only.tools/ioctl_capture/replay_diff.py:goldenreduces raw captures to a handle-free transcript;diffaligns a candidate with it step by step and gates on a baseline.captures/stock/*.jsonl: raw stock recordings (evidence, category[O]). Not committed: they embed the GPU UUID. Re-record locally withcapture_stock.sh.captures/golden/stock-620.73.04.json,controls.tsv: normalised transcript and the control set.captures/golden/known-gaps.tsv: controls the stock driver served that our 580-derived table does not match. The offline test fails on a new entry and on a stale one.captures/baseline/*.json: divergences of the candidate driver you accept, written locally byreplay_live.sh --update(not committed; the live gate fails on a new divergence and reports fixed ones, so a baseline only shrinks).- Workloads:
nvidia-smi -L,nvidia-smi,tools/ioctl_capture/cuda_basic.py(cuInit, context, alloc, H2D, D2H, free, destroy). Add a workload by recording it withrunand listing it inreplay_live.shandreplay_diff.py golden.
Re-recording (needs the user's explicit yes)
The swap unloads nvidia_rs and loads the stock modules built for the running kernel
(STOCK_SRC, default ../nvidia-open-620.73.04/kernel-open, from the NVIDIA tag
620.73.04, make modules SYSSRC=/usr/lib/modules/$(uname -r)/build). It is opt-in: set
NV_RS_CAPTURE_BDF=<bdf> to the one GPU it may unbind; it refuses if nvidia_rs is bound to any
other device, so it cannot touch a multi-GPU host by accident. Never reset the GPU or
reboot from the script. After swap, run sudo nvidia-modprobe -c0 -u -m if the nodes are missing.
restore drops caches and compacts memory first: after the stock driver ran, DMA32 order-7
allocations fail with runtime initialization failed: -12 otherwise.
What the golden transcript shows (stock 620.73.04)
nvidia-smiand a CUDA round trip (cuInit…cuCtxDestroy) succeed; the CUDA workload is 551 ioctls over 65 distinct controls and 18 allocation classes.- Not covered: nested pointers inside parameter buffers, mmap contents, GPU-side effects.