Translation Lookaside Buffer

From Free net encyclopedia

A Translation Lookaside Buffer (TLB) is a buffer (or cache) in a CPU that contains parts of the page table which translate from virtual into real addresses. This buffer has a fixed number of entries and is used to improve the speed of virtual address translation. The buffer is typically a content addressable memory (CAM) in which the search key is the virtual address and the search result is a real or physical address (which is often not the same thing). If the CAM search yields a match the translation is known and the match data are used. If no match exists the translation proceeds via the page table, which will take several more cycles to complete – particularly if the translation tables are swapped out into secondary storage.

The TLB references physical memory addresses in its table. The TLB may reside between the CPU and the cache, or between the cache and primary storage. This depends on whether the cache is using virtual addressing or physical addressing.

If the cache is virtually addressed, requests are sent directly from the CPU to the cache, which then accesses the TLB as necessary. If the cache is physically addressed, the CPU does a TLB lookup on every memory operation, and the resulting physical address is sent to the cache. There are pros and cons to both implementations.

A common optimization for physically-addressed caches is to perform the TLB lookup in parallel with the cache access. The low-order bits of any virtual address (e.g., in a virtual memory system having 4KB pages, the lower 12 bits of the virtual address) do not change in the virtual-to-physical translation. On any cache access, there are two operations that are performed: an index into the cache's data store, and then a comparison of the tags for the cache line found. If the cache is structured in such a way that it can be indexed using only the bits that do not change in translation, the cache can perform its "index" operation while the TLB translates the upper bits of the address. Then, the translated address from the TLB is passed to the cache. The cache performs a tag comparison to determine if this access was a hit or miss. See the address translation section in the cache article for more details about virtual addressing as it pertains to caches and TLBs.

Miss

When a TLB miss occurs, two schemes are commonly found in modern architectures. With hardware TLB management, the CPU itself walks the page tables to see if there is an entry for the specified virtual memory address. If there is, the entry is brought into the TLB and the TLB access is retried (this can get complicated depending on whether it was a data or instruction TLB miss). If there is no entry in the page table, a page fault exception occurs, and the operating system must bring the required data into memory. With software-managed TLBs, a TLB miss generates a "TLB miss" exception, and the operating system must walk the page tables and perform the translation in software. The operating system then loads the translation into the TLB and restarts the program from the instruction that caused the TLB miss.

Typical statistics

Size: 8 - 4,096 entries
Hit time: 0.5 - 1 clock cycle
Miss penalty: 10 - 30 clock cycles
Miss rate: 0.01% - 1%

If a hit takes 1 clock cycle, a miss takes 30 clock cycles, and the miss rate is 1%, the effective memory cycle rate is <math>1*.99 +30*.01 = 1.29</math> clock cycles per memory access.

Computer security

Although not intended by design, if system security has been breached, a rootkit may use the translation lookaside buffer to alter the view of memory in order to hide a subversive program or backdoor on a computer.de:Translation Lookaside Buffer es:Translation Lookaside Buffer it:Translation Lookaside Buffer ja:トランスレーション・ルックアサイド・バッファ pl:Translation Lookaside Buffer pt:Translation Lookaside Buffer