10-ImprovePaging
10-ImprovePaging
• Required Readings
• Chapter 19 – Paging: Faster Translation (TLBs)
• http://pages.cs.wisc.edu/~remzi/OSTEP/vm-tlbs.pdf
• Chapter 20 – Paging: Smaller Tables
• http://pages.cs.wisc.edu/~remzi/OSTEP/vm-smalltables.pdf
Can give good performance in address translation even with relatively small
TLB due to principle of locality
• An instruction or data item that has been recently accessed will likely be re-
accessed soon in the future – Temporal locality
• A program accesses memory at address x, likely to access memory near x in
the nearby future – Spatial locality
MMU
Access a MMU gets
checks TLB hit Obtain page
virtual address virtual page # frame # from TLB
TLB Y
N
Just one memory access
TLB miss for fetching the data item
An extra memory access
MMU updates
MMU access Access physical
TLB
process’s page table memory
MMU obtains
page frame #
19
511
37
27
14
211
127
parallel in a content-
768
based manner using the 38
target VPN as the key 15
The VPN is compared simultaneously with the VPN field Physical address
• If shared, system does not need to flush TLB on context switch; then, how can
MMU identify the set of TLB entries that is relevant to current running process?
• Some systems add an extra field – Address Space Identifier, in the TLB, to indicate which
process “owns” this TLB entries
• When there is a TLB miss, the system has to install a new entry in TLB. It
is possible that all entries are in used, we have to “kick out” one entry to
make way for the new one. Which one to replace?
• Simply increases size of a page, that should reduce size of a page table
• Increase page size to 16 KiB, a page table needs to store 218 entries. If each entry is
of 4-byte, the size of a page table becomes 1 MiB
• Within a page table, not all PTEs (Page Table Entries) refer to valid
virtual pages. If the system just needs to allocate physical memory
to used PTEs, that would consume less memory.
• The Crux
• Is there any way just to store part of the page table in physical memory?
• The cruxes
• How can we know whether a page unit contains valid pages?
• How can we locate the “smaller” page tables?
Example table
210 PTEs
tables frames
212 bytes
210 PDEs
Page directory
• A two levels scheme typically used by 32-bit address
Page table
4 KiB
page
space, e.g. x86
• Size of each virtual page = 212 = 4 KiB
• Total no. of PTEs in a linear page table = 232/212 = 220 PTEs
• Assume each PTE is of 4-byte
• Each frame can store 212/4 = 210 entries (PTEs)
• Entire page table is divided into 220/210 = 210 small page •
tables •
• 220 PTEs
• We need 210 entries (PDEs) in the directory table
• MMU needs to know where to find the address of the page
directory – page directory base register (PDBR)
Virtual page number
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 0 1 1 1 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 1 0 1 0 1 0 1 1 1 1 1 1
• Collision
• One or more virtual pages may hash to the same PTE
• A linked list to chain up those pages that have the same hash value
• The IBM PowerPC and Intel IA-64 (Itanium) are two examples of such an
architecture
Summary
• By using a small but fast TLB to cache recently used address translation
info, this greatly improves the performance of the paging system.
• Breaking the entire page table into page-sized units and only allocate
physical memory to store used smaller page tables – that significantly
reduces the memory consumption