Repository navigation
jitv2: park a lone cpu for a worker's flush instead of halting it - #826
Merged
techomancer merged 3 commits intoNov 22, 2026
Merged
techomancer merged 3 commits into
techomancer merged 3 commits into
Conversation
A compile worker that filled its arena led a flush by calling cpu.stop() on a CPU with a pool of its own, which joins the CPU thread. If that CPU ran out of JIT pages in the meantime, it was in flush_from_cpu_thread, holding Mutex<Jitv2> and joining the worker: each waited for the other. j2 flush and j2 inline on from the monitor hung the same way, on the executor or the Jitv2 lock. Machines with several CPUs on one pool already took turns through World; a lone CPU's pool had none. Every pool now flushes through the world of its CPUs. attach_pool takes the machine's world, and every machine passes it: the Indy, Indigo2 and O2 (whose worlds carried only remap requests), the Octane and Tezro with one CPU, and every pool share_pool builds, also a lone processor's or a node whose module has a pool of its own. Each CPU on the pool shares it with share_jitv2, which now sets the world on the pool as well, so the CPU's stop_others and the worker's try_lead take turns on one world. A CPU belongs to one world, since two would both hold it with HOLD_WORLD. MipsCpu::new gives every CPU a World::solo until a machine replaces it, for CPUs built without one. The worker then parks the CPU and gives way if the pool stops, and the CPU's own flush, inside stop_others, counts as parked while it waits its turn. A worker's flush also no longer restarts a CPU the monitor has stopped. j2 inline on stops the pool through Jitv2::stop_pool, which joins with the lock released. The start-up half of techomancer#306 (workers taking the lock to read the cache geometry) was fixed in 9503188. New test a_cpu_flush_inside_a_worker_led_flush_takes_its_turn forces a worker flush (a test-only PoolBarrier hook) against a CPU that flushes the moment it is held. Without the world it times out after 20 s; with it, it passes in under 0.1 s. Fixes techomancer#306. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/jitv2-flush-race.py boots a single-CPU guest under --ci with IRIS_JIT_ARENA_FLUSH_MB=1, so the compile workers lead flushes of their own throughout the boot, and loops stop / j2 flush / start at the monitor. A j2 flush that does not return within --cmd-timeout is the deadlock of techomancer#306; the script then saves every thread's stack (--stacks) and kills iris, whose disk overlay --ci keeps in $TMPDIR. On the Indigo2 R10000 with IRIX 6.5.22, upstream bd81b63 hung both times (after 22 rounds in 73 s, and after 1 round during the PROM's diagnostics): the monitor thread joining jitv2-compile-0 inside CompileQueue::stop, the worker in MipsCpu::halt waiting for the executor lock the monitor holds. With the fix it ran 1115 rounds in 600 s with 1234 worker-led flushes, and the guest reached its login prompt. TESTING.md describes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
hopefully we will soon have double buffered arena ;-) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What #306 reported
Under jitv2, two flushes can deadlock. A compile worker that fills its code arena leads a flush and stops the CPU with
cpu.stop(), which joins the CPU thread. At the same moment the CPU side may flush too: the CPU running out of JIT pages, orj2 flush/j2 inline onfrom the monitor. That flush holds theJitv2lock and joins the worker. Each waits for the other.The start-up half of the issue (a worker taking the lock to read the cache geometry) was already fixed in 9503188. What remained is a pool with a single CPU: the Indy, Indigo2, O2, a one-CPU Octane or Tezro, or an Origin node whose processor module has a pool to itself. Such a pool had no
World, so its worker still halted the CPU.The fix
attach_pooltakes the machine's world, and every machine passes it, so the CPU'sstop_othersand the worker'stry_leadtake turns on the same world. This covers the Indy, Indigo2 and O2 (whose worlds carried only remap requests until now), a one-CPU Octane or Tezro, and every groupshare_poolbuilds.MipsCpu::newgives each CPU aWorld::solountil a machine replaces it (share_jitv2); that covers CPUs built outside a machine, as in tests.j2 inline onstops the pool withJitv2::stop_pool, which joins the workers with the lock released.How I reproduced it
tools/jitv2-flush-race.py(new, described inTESTING.md) boots a guest under--ciwithIRIS_JIT_ARENA_FLUSH_MB=1, so the workers lead flushes of their own throughout the boot. Meanwhile it loopsstop/j2 flush/startat the monitor. Aj2 flushthat does not return within 60 s counts as the deadlock; the script then saves every thread's stack and kills iris. That is safe because the disk overlay of a--cirun lives in$TMPDIR.The guest was an Indigo2 IP28 (R10000, Solid IMPACT) running IRIX 6.5.22, installed from original media, on a
--cicopy-on-write overlay. The builds were release--features jitv2.bd81b637j2 flushnever returned after 22 rounds (73 s, 17 worker-led flushes); guest at "The system is coming up."bd81b637IRIS console login:IRIS console login:Stacks of the hung upstream iris (macOS
sample), condensed:The flush runs were made on
bd81b637. After rebasing ontodb7e3836(a gfifo loom model, outside these files), I reran only the targeted unit tests.Tests
a_cpu_flush_inside_a_worker_led_flush_takes_its_turn: it forces a worker flush (a test-onlyPoolBarrierhook) against a fake CPU that flushes the moment it is held. Without the world it times out after 20 s; with it, it passes.a_solo_world_holds_its_cpu_for_others_but_not_for_itself.cargo test --workspace --features jitv2 -- --skip dev::kona::back::tilespassed in full on the previous base (lib 5510 passed, 0 failed); the Kona tile tests were skipped because their hang fix is on another branch.cargo checkwith default features is clean.Not covered
j2 flush, uses the sameflush_from_cpu_threadpath but was not provoked separately. Thej2 inline onpath was not run live.Fixes #306.
🤖 Generated with Claude Code