|
<< Click to Display Table of Contents >> Navigation: ASA-EMulatR Reference Guide > Introduction > Architecture Overview > Chapter 17 – Address Translation, TLB, and PTE > 17.7 ASN Management and Coherence |
The Alpha architecture tags TLB entries with an Address Space Number (ASN) to avoid full TLB flushes on context switches. When the OS switches to a process with a different ASN, only the TLB entries tagged with the old ASN become stale — entries tagged with the new ASN or marked as global (ASM bit set) remain valid.
ASN width is generation-dependent. The EV6 supports up to 8-bit ASNs (256 address spaces). When ASN space is exhausted, the OS performs an ASN wraparound: it allocates a new ASN generation and invalidates all non-global entries. The SPAMShardManager supports this via invalidateASN() and the maintenanceTick() sweep.
SMP coherence for ASN invalidation uses a shared ASN epoch table, accessed via globalASNEpochs() (no CPU ID — this is shared state). Each ASN has an epoch counter. When the OS invalidates an ASN, the epoch counter is incremented. Per-CPU SPAM entries are tagged with the epoch at insertion time; on lookup, a stale epoch (entry epoch < current epoch) indicates the entry is invalid without requiring an explicit per-entry flush.
This lazy invalidation approach avoids the cost of scanning all buckets across all CPUs when an ASN is recycled. The actual eviction happens naturally when the stale entry is encountered during lookup or when a replacement policy selects it as a victim.
PTE entries with the ASM (Address Space Match) bit set are global — they match all ASNs and are not invalidated by ASN-scoped operations (TBIAP). Only TBIA (invalidate all) or TBIS (invalidate single VA) can remove global entries. Global entries are used for kernel text and data mappings that are shared across all processes.
The Ev6TLBTag includes a matchAllASNs flag that controls whether the entry participates in ASN matching during lookup.
See Also: 8.3 Privilege Levels (kernel/user mode context); 9.4 Per-CPU vs Shared State (ASN epochs as shared state).