Console CPU instructions: monitorx / mwaitx are rewritten in place at their first fault #2618
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2618
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2618"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@lukastaro on GitHub · 2026-11-26 02:27 UTC · original
lukastaro:pr-patch-waits→main· +86 −1 · 1 files · 1 commits · openA title that paces its frames with
monitorx/mwaitxspins on them. On a CPU without them (Intel) every one raises an illegal-instruction exception thatehemulates, the same instruction again and again.clwbis already rewritten to nops at its first fault; this does the same for these two:monitorx→ nops,mwaitx→pause+ nops (a wait that ended at once; the title checks its own condition again, as it must after anymwaitx).Tested
cargo test --workspace --no-fail-fast -- --test-threads=4on19aa5c2: 1426 passed, 11 failed, 47 ignored. Onmainb49be18the same run: 1425 passed, 10 failed, 47 ignored, the same 10 failures (fuzz_validate_and_gpu_0–_3, the twolink_tests,vram::tests::d32s8_targets_take_their_own_size_of_video_memoryand the threetest_title_*integration tests). The 11th,list_x::tests::a_reset_while_the_last_submit_runs_records_on_another_pc_list, passed 3 of 3 times alone.monitorx_and_mwaitx_are_rewritten_at_their_first_fault(both rewritten, rip stepped over them),code_across_an_aligned_word_is_not_rewritten.Regression run
main:
PR:
The 60 s stay in the title's menus; the two sites are rewritten in the first seconds.
Not tested
monitorx/mwaitxnatively and never reach this path.AI use
🤖 Generated with Claude Code
@DavidM1911 on GitHub · 2026-11-26 02:35 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.Thanks!
— Devin
@ -248,0 +271,4 @@let mut bytes = was.to_le_bytes();bytes[off..off + new.len()].copy_from_slice(new);// another thread may have rewritten it first: then it holds the same bytes alreadylet _ = cell.compare_exchange(was, u64::from_le_bytes(bytes), Ordering::AcqRel, Ordering::Acquire);@luckyteagirl on GitHub · 2026-11-26 03:15 UTC · original
A failed
compare_exchangeis currently ignored, but another thread may have rewritten a differentmonitorx/mwaitxsite in this same aligned 8-byte word. If both load the original word, one CAS wins and the other loses; the losing site remains unchanged even thoughrewrite_codereturnstrue, so later visits fault again. Could this retry after a lost CAS by reloading and merging only the requested bytes? A deterministic test with two adjacent sites would cover it. This is a source-derived interleaving, not a measured title failure.@ -248,0 +263,4 @@// SAFETY: `word` is the aligned word around code the processor just fetched; it is made// writable for the one store and given its protection backunsafe {if VirtualProtect(word as *const c_void, 8, PAGE_EXECUTE_READWRITE, &mut old) == 0 {@luckyteagirl on GitHub · 2026-11-26 03:15 UTC · original
VirtualProtect(word, 8, ...)changes the whole containing page. Two concurrent calls on that page can save RX/RWX respectively; if the first restores RX before the second restores its saved RWX, the page stays writable and executable.SEENis unlocked before this span. Could the protect/CAS/restore span be serialized for calls touching the same page, with a concurrent-patch test asserting the original protection afterwards? This is a source-derived interleaving, not a measured title failure.@DavidM1911 on GitHub · 2026-11-26 08:29 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
@luckyteagirl on GitHub · 2026-11-26 03:15 UTC · original · reviewed
Two source-derived concurrency points on the current head. No local build or title run. AI-assisted source review: OpenAI Codex (GPT-6; exact serving variant unavailable) and a Luna subagent.
github-bot referenced this pull request2026-11-26 12:40:17 +00:00
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.