notes

Does an aarch64 CI host show a guest reorderings an x86_64 host hides?

An appendix to notes/benchmarks.md, measured 2026-10-24 (UTC) by the lane maintainer/measure-arm64-host-reordering. Name: provisional (that lane). It tests the claim .github/workflows/ci.yml gives for keeping the SMP QEMU jobs on ubuntu-26.04-arm. Milestone 587 (most CI jobs do not need an arm64 host) records that claim as recalled from QEMU's documentation rather than measured.

The answer

Two halves, and they come apart.

So the arm64 placement buys exposure the suite does not use. It is partial: it earns its cost only with a dedicated contended test, which the tree does not have.

What QEMU 11.1.2 predicts

.qemu-version pins 11.1.2. References are to its source tarball.

The prediction: on an x86_64 host the guest sees exactly TSO. Message passing (MP) cannot reorder however weak the guest's code, and store buffering (SB) can. On an aarch64 host the guest sees what the host's own cores allow, which includes MP. One more falls out of the third bullet: STLR then LDAR puts no barrier between the store and the load, so an aarch64 guest's SeqCst store followed by a SeqCst load can reorder on either host, which Armv8 forbids.

The method

The litmus guest

tools/host_reordering_litmus is a bare-metal program for QEMU's virt machine, built for aarch64-unknown-none-softfloat and riscv64imac-unknown-none-elf, the kernel's own targets, so its atomics lower the way the kernel's do. Four cores; the aarch64 build turns the MMU on so the litmus lines are Normal, inner-shareable memory. Each test's instruction order was checked in the disassembly: the compiler keeps program order for every variant, so a reordering counted is the host's.

The weakened suite

weaken-spin.sh edits crates/test_and_set_lock in place to make its unlock Relaxed (release), or that and its compare-exchanges Relaxed (both). Then script/test --arch aarch64,riscv64 --no-host runs, NIFE_SMP at its default of 4, as many times as fit a bounded job. The suite counts below ran against spin 0.12.3 patched the same two ways, before the kernel's lock moved into the tree; the build logs show the patched crate compiled in.

The hosts

A temporary workflow ran the same steps on ubuntu-24.04-arm (Neoverse-N2, 4 vCPUs) and ubuntu-24.04 (AMD EPYC 7763, 9V45 and 9V74, 4 vCPUs), QEMU 11.1.2 from the CI cache, LITMUS_SCALE 60.

The counts

Runs 40067282280 (MP, SB; suite release) and 40068823516 (MP, SB, LOCK; suite both). Each cell is per million, first run / second run.

guest, test, ordering aarch64 host x86_64 host
aarch64 MP release/acquire 0 / 0 0 / 0
aarch64 MP relaxed/relaxed 87,802 / 82,635 0 / 0
aarch64 MP release/relaxed (reader reorders) 170 / 259 0 / 0
aarch64 MP relaxed/acquire (writer reorders) 11,834 / 25,461 0 / 0
riscv64 MP release/acquire 0 / 0 0 / 0
riscv64 MP relaxed/relaxed 61,624 / 68,025 0 / 0
riscv64 MP release/relaxed 600 / 671 0 / 0
riscv64 MP relaxed/acquire 3,700 / 4,479 0 / 0
aarch64 SB relaxed 19,551 / 17,453 16,726 / 210,567
aarch64 SB SeqCst 50,275 / 1,640 7,146 / 61,431
aarch64 SB SeqCst fence 0 / 0 0 / 0
riscv64 SB relaxed 2,298 / 3,491 8,015 / 24,886
riscv64 SB SeqCst, and SeqCst fence 0 / 0 0 / 0
aarch64 LOCK, Release unlock (not run) / 0 (not run) / 0
aarch64 LOCK, Relaxed unlock (not run) / 201,943 (not run) / 0
riscv64 LOCK, Release unlock (not run) / 0 (not run) / 0
riscv64 LOCK, Relaxed unlock (not run) / 5,290 (not run) / 0

Per million messages for MP (240 million a test), slot pairs for SB (61 million), increments for LOCK (48 million). MP repeats within a factor of 2.2. SB swings by up to 30 times between runs, because how often two cores reach the same slot together depends on how the barrier releases them; it is a presence test, not a rate. Every zero is zero in both runs.

The suite, weakened. Every run passed all 141 and 388 aarch64 tests and all 144 and 385 riscv64 tests (14 skipped in each system_tests, as unweakened):

weakening aarch64 host x86_64 host
release (40067282280) 2 runs, green 3 runs, green
both (40068823516) 2 runs, green 2 runs, green

Two more release runs on a local x86_64 machine passed every test and failed only the page frame ledger, which the same checkout also fails unweakened. That is a checkout-location effect, now in the BUGS of the page frame budget, and not the weakening.

The kernel's lock, measured beside the shaped copy

Run 40248532720, the same hosts and scale, twice per host, after the kernel's lock became crates/test_and_set_lock. The shaped copy's release-unlock row is the lock as it was; the spin-lock-crate row is the lock the kernel takes now. Milliseconds of guest time for 48 million contended increments, first run / second run, and every lost-update count of both rows is 0:

guest, host shaped copy, Release crates/test_and_set_lock shaped copy, Relaxed: lost per million
aarch64, aarch64 host 5,088 / 6,073 5,646 / 5,698 99,268 / 139,640
riscv64, aarch64 host 1,224 / 1,308 1,342 / 1,531 474 / 4
aarch64, x86_64 host 7,202 / 9,640 6,866 / 11,007 0 / 0
riscv64, x86_64 host 1,732 / 2,687 1,806 / 2,552 0 / 0

The same guest on a local x86_64 machine (Xeon Platinum 8160) gave 22,429 against 17,599 for aarch64 and 2,377 against 2,576 for riscv64. The two locks differ by less than one row's own spread between its two runs, which reaches 40% on the x86_64 runner, so the timing is a tie within noise. The crate keeps its counter on the flag's line, as a kernel lock's data is, where the copy does not, so the two are not the same experiment to the cycle. The Relaxed control still loses updates on the aarch64 host, so the run could have seen a broken lock.

What it means for the arm64 jobs

The SMP QEMU jobs on ubuntu-26.04-arm are the only CI jobs that put guest code where a missing Release can show. The suite they run does not look: no kernel lock with no ordering at all failed a test on either host. On today's suite the placement buys nothing measurable for lock ordering, and it spends runner time in the queue that waits longest.

The exposure is real and cheap to use. The LOCK test, a minute of guest time, turns a Relaxed unlock into 20% lost updates on an aarch64 host and nothing on x86_64. A kernel test of that shape (cores contending one InterruptSafeMutualExclusionLock and checking the data it guards, with weaken-spin.sh as its falsification) would make one arm64 job earn its place. Without it, loom, review and the HVF runs on Apple silicon hold rule 4 of the codebase rules, and CI's host does not.

The x86_64 guest legs on arm64 (test-x86_64, rg-threads-x86_64) are a different case, a guest stronger than its host; nothing here measures them.

BUGS