Repository navigation
cpu: narrow the untagged-TLB barrier at ASID-preserving writes and nested exceptions - #945
Merged
Conversation
Owner
|
ok this looks promising, will check later |
…sted exceptions nanotlb_invalidate cleared nanotlb[0..3], both nutlb ways and the jitv2 pcp even when no cached translation could have changed. - MTC0/DMTC0 EntryHi (reg 10): pass the previous cp0_entryhi into handle_cp0_side_effects; flush only if the ASID bits [7:0] changed. VPN2/region writes are not a barrier. IRIX writes EntryHi on every TLB refill, so this is hot. - TLBR: capture old EntryHi before the read; flush only on an ASID change (TLBR does not write the TLB). - All three exception paths: capture cp0_status before deliver_exception[_at] and call resync_privilege_state_filtered with (old ^ new) & TRANSLATION_STATUS_MASK != 0. A nested exception with EXL already set changes no translation bit, so the nutlb survives; a first exception or cache error (ERL) still flushes. translate_fn and FPR mode are always re-derived. ERET, TLBWI/TLBWR, K0 config writes, layout changes, restore/reset are unchanged. per-CPU state only; SMP-safe. New regression test test_mtc0_entryhi_with_same_asid_keeps_the_nutlb. cargo check clean; mips_exec_test 218, jitv2 523, new tlbstats test passed. Rebased onto main without techomancer#943/techomancer#944 (conflicts in CHANGELOG.md and clanker/INDEX.md resolved to this change's own entries). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
techomancer
force-pushed
the
perf/nutlb-flush-narrow
branch
from
December 1, 2026 04:53
9faaa85 to
36828d6
Compare
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.
Summary
Next TLB-path PR after #943 and #944. Narrow
nanotlb_invalidate()to the events that can actually change a cached translation.nanotlb_invalidate()clearsnanotlb[0..3], both ways ofnutlb_valid(now two-way after #944), and the jitv2pcp; several hotspots fired it when nothing translation-relevant moved.Narrowed sites
MTC0/DMTC0 EntryHi(reg 10):handle_cp0_side_effectstakes the previouscp0_entryhiand flushes only when(old ^ new) & 0xFF != 0. VPN2/region bits are not in a nutlb tag. IRIX writes EntryHi on every TLB refill, so this is hot.TLBR: captures the old EntryHi before overwriting it; flushes only if the ASID changed (TLBR does not write the TLB).cp0_statusbeforedeliver_exception[_at], then callresync_privilege_state_filtered((old ^ new) & TRANSLATION_STATUS_MASK != 0). A nested exception arriving with EXL already set changes no EXL/ERL/privilege/mode bit (EPC/Cause/vector do not feed translation) so the per-CPU nutlb working set survives. A first exception (EXL 0→1) or a cache error (ERL) still flushes.Unchanged:
exec_eret,TLBWI/TLBWR, K0 config writes, jitv2 layout/geometry change, snapshot/restore, soft reset.Why correct / SMP
The nutlb is valid only while the VA→PA meaning of its tags holds; that meaning changes on privilege/mode, ASID, a TLB write, or a memory remap. None of the narrowed sites changes those.
translate_fn/FPR mode are still always re-derived in the exception paths; jitv2pcpstays valid because the exception vector is a different page, so the fetch nanotlb misses and re-derivespcp. All touched state is per-CPU — no shared state or ordering changes; safe for 4-vCPU Fuel/Tezro (please verify on the Tezro).Verification
cargo check -p iris --features jitv2clean.mips_exec_test218 passed,jitv2523 passed, and the newtest_mtc0_entryhi_with_same_asid_keeps_the_nutlb(tlbstats) passed; existing ASID-change/TLBR regression tests still pass. Not guest-measured — please runiris-benchand an SMP IRIX boot on the Tezro.Docs:
docs/nutlb-design.md§1a;CHANGELOG.md;clanker/cpu/narrow-nutlb-flush-sites.md+clanker/INDEX.md.