Professional Documents
Culture Documents
Engineering
Krste Asanovic
Electrical Engineering and Computer Sciences
University of California at Berkeley
http://www.eecs.berkeley.edu/~krste
http://inst.eecs.berkeley.edu/~cs152
Last time in Lecture 9
• Protection and translation required for
multiprogramming
– Base and bounds, early simple scheme
• Page-based translation and protection avoids need
for memory compaction, easy allocation by OS
– But need to indirect in large page table on every access
• Address spaces accessed sparsely
– Can use multi-level page table to hold translation/protection
information
• Address space access with locality
– Can use “translation lookaside buffer” (TLB) to cache address
translations (sometimes known as address translation cache)
– Still have to walk page tables on TLB miss, can be hardware or
software talk
• Virtual memory uses DRAM as a “cache” of disk
memory, allows very cheap main memory
2/28/2008 CS152-Spring’08 2
Modern Virtual Memory Systems
Illusion of a large, private, uniform store
10-bit 10-bit
L1 index L2 index offset
Root of the Current
Page Table p2
p1
(Processor Level 1
Register) Page Table
Level 2
page in primary memory Page Tables
page in secondary memory
Read/Write
Protection Address
Check Translation
Exception?
Physical Address Physical Page No. (PPN) offset
2/28/2008 CS152-Spring’08 7
Translation for Page Tables
• Can references to page tables cause TLB misses?
• Can this go on forever?
Data Pages
2/28/2008 CS152-Spring’08 8
Variable-Sized Page Support
Virtual Address
31 22 21 12 11 0
p1 p2 offset
10-bit 10-bit
L1 index L2 index offset
Root of the Current
Page Table p2
p1
(Processor Level 1
Register) Page Table
Level 2
page in primary memory
Page Tables
large page in primary memory
page in secondary memory
PTE of a nonexistent page
Data Pages
2/28/2008 CS152-Spring’08 9
Variable-Size Page TLB
Some systems support multiple page sizes.
V R WD Tag PPN L
hit?
2/28/2008 CS152-Spring’08 10
Address Translation:
putting it all together
Virtual Address
hardware
Restart instruction hardware or software
TLB
software
Lookup
miss hit
Page Fault
Update TLB Protection Physical
(OS loads page) Address
Fault
(to cache)
SEGFAULT
2/28/2008 CS152-Spring’08 11
Address Translation in CPU Pipeline
2/28/2008 CS152-Spring’08 13
Aliasing in Virtual-Address Caches
Page Table Tag Data
VA1
Data Pages VA1 1st Copy of Data at PA
2/28/2008 CS152-Spring’08 15
Concurrent Access to TLB & Cache
Virtual
VA VPN L b Index
Direct-map Cache
TLB k
2L blocks
2b-byte block
PA PPN Page Offset
Tag
=
Physical Tag Data
hit?
Index L is available without consulting the TLB
⇒ cache and TLB accesses can begin simultaneously
Tag comparison is made after both accesses are completed
Virtual
VA VPN a L = k-b b 2a Index
Direct-map Direct-map
TLB k 2L blocks 2L blocks
Phy.
PA PPN Page Offset Tag
= =
Tag hit? 2a
Data
After the PPN is known, 2 physical tags are compared
a
= hit?
Tag
2/28/2008 CS152-Spring’08 18
A solution via Second Level Cache
L1
Instruction Memory
Cache Memory
Unified L2
CPU
Cache Memory
L1 Data
RF Memory
Cache
2/28/2008 CS152-Spring’08 19
Anti-Aliasing Using L2: MIPS R10000
2/28/2008 CS152-Spring’08 20
Virtually-Addressed L1:
Anti-Aliasing using L2
Virtual
VA VPN Page Offset b Index & Tag
VA1 Data
TLB
VA2 Data
2/28/2008 CS152-Spring’08 22
Hierarchical Page Table
Virtual Address t he
31
s
22 21rse 12 11 0
p1 rav p2
e e.
t “ o
n mo d
offset
t
tha ds a sing
r a m 10-bit
e e e10-bit
s
g n r
p ro ablL1 e index
a dd L2 index offset
ARoot eoft theoCurrent
n ”
g ati
pa Page
n sl Table p2
tra p1
(Processor Level 1
Register) Page Table
Level 2
page in primary memory Page Tables
page in secondary memory
Why?__________________________________
2/28/2008 CS152-Spring’08 24
Atlas Revisited
2/28/2008 CS152-Spring’08 25
Hashed Page Table:
Approximating Associative Addressing
User map
Global
System Physical
Level A map
Address Memory
Space Level B
User map
2/28/2008 CS152-Spring’08 27
Hashed Page Table Walk:
PowerPC Two-level, Segmented Addressing
64-bit user VA Seg ID Page Offset
0 35 51 63
hashS
Hashed Segment Table
PA of Seg Table +
per process PA
hashP
Hashed Page Table
PA of Page Table + PA
system-wide
0 27 39
[ IBM numbers bits
with MSB=0 ] 40-bit PA PPN Offset
2/28/2008 CS152-Spring’08 28
Power PC: Hashed Page Table
VPN d 80-bit VA
Page Table
Offset PA of Slot
hash + VPN
VPN
PPN
Base of Table
• Each hash table slot has 8 PTE's <VPN,PPN> that are
searched sequentially
• If the first hash slot fails, an alternate hash function is
used to look in another slot
All these steps are done in hardware!
• Hashed Table is typically 2 to 3 times larger than the
number of physical pages
Primary
• The full backup Page Table is a software data structure
Memory
2/28/2008 CS152-Spring’08 29
Virtual Memory Use Today - 1
2/28/2008 CS152-Spring’08 30
Virtual Memory Use Today - 2
2/28/2008 CS152-Spring’08 31
Acknowledgements
• These slides contain material developed and
copyright by:
– Arvind (MIT)
– Krste Asanovic (MIT/UCB)
– Joel Emer (Intel/MIT)
– James Hoe (CMU)
– John Kubiatowicz (UCB)
– David Patterson (UCB)
2/28/2008 CS152-Spring’08 32