Skip to content

snapshot: re-anchor the mc timebase on start - #63

Merged
techomancer merged 1 commit into
techomancer:mainfrom
sgidevnet:snapshot-restore-4
Jul 31, 2026
Merged

snapshot: re-anchor the mc timebase on start#63
techomancer merged 1 commit into
techomancer:mainfrom
sgidevnet:snapshot-restore-4

Conversation

@mach-kernel

@mach-kernel mach-kernel commented Jul 30, 2026

Copy link
Copy Markdown
Contributor
Changes
  • Re-anchor last_host_ticks in MemoryController::start(), after the running.swap guard so a redundant start does not discard live elapsed time.
  • Not in load_state: machine.rs:1448 runs it well before the bulk memory restore at 1503-1526, and restart_peripherals() is the last statement of load_snapshot_inner.
  • cpu_cycle_acc and rpss_cycle_acc are left alone; power_on already zeroes them and runs first on every restore path.
Coverage / needs eyes
  • mc::tests::start_reanchors_timebase stales the anchor by 100 s, calls start(), reads REG_RPSS_CTR. Reverting the one-line fix fails it at 1500000954 counts, the predicted 1.5e9 for 100 s at 50 MHz. With the fix the same read lands at 777-831 counts over four runs.
  • cargo test --release --features lightning,rex-jit,chd: 358 passed, 11 ignored.
  • Found via one update_timers step of cpu_cycles=16630691385 after a snapshot restore, RPSS_CTR 0x24d1b19 to 0xc88ead47.
  • Does not cover a CPU-only pause. gdb_stub.rs:726/810 and the monitor cpu stop command stop the CPU without stopping the MC, so start() never runs and a held breakpoint is still billed on the next MC read. Worth a follow-up, left out to keep this to one thing.

Nothing re-anchors last_host_ticks across a stop, so the first MC read
after a pause credits the whole stopped interval to RPSS_CTR.
@mach-kernel mach-kernel changed the title [Snapshot Restore] re-anchor the MC timebase when the machine starts [Snapshot Restore] Re-anchor the MC timebase on start Jul 30, 2026
@mach-kernel mach-kernel changed the title [Snapshot Restore] Re-anchor the MC timebase on start snapshot: re-anchor the mc timebase on start Jul 30, 2026
@techomancer
techomancer merged commit 179b71d into techomancer:main Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants