ECE 550D
Fundamentals of Computer Systems and Engineering
Fall 2016
Virtual Memory
Tyler Bletsch Duke University Slides are derived from work by Andrew Hilton (Duke), Dan Sorin (Duke), and Amir Roth (Penn)
ECE 550D Fundamentals of Computer Systems and Engineering Fall 2016 - - PowerPoint PPT Presentation
ECE 550D Fundamentals of Computer Systems and Engineering Fall 2016 Virtual Memory Tyler Bletsch Duke University Slides are derived from work by Andrew Hilton (Duke), Dan Sorin (Duke), and Amir Roth (Penn) DRAM Packaging Just talked
Tyler Bletsch Duke University Slides are derived from work by Andrew Hilton (Duke), Dan Sorin (Duke), and Amir Roth (Penn)
2
3
4
Application OS Firmware Compiler I/O Memory Digital Circuits Gates & Transistors CPU
5
6
7
Cache Copy if popular
7 RAM
(or SSD)
Hard disk Load if needed
Drop
Swap out (RW) or drop (RO)
8
9
code heap stack
10
11
12
POFS[15:0] virtual address[31:0] VPN[31:16] POFS[15:0] physical address[27:0] PPN[27:16] translate don’t touch
13
struct { union { int ppn, disk_block; } int is_valid, is_dirty; } PTE; struct PTE pt[NUM_VIRTUAL_PAGES]; int translate(int vpn) { if (pt[vpn].is_valid) return pt[vpn].ppn; } PT vpn
14
SEGFAULT OK (fast) OK (fast) OK (but slow)
! Virtual memory Page table Physical memory HDD/SSD storage
15
Adapted from Operating System Concepts by Silberschatz, Galvin, and Gagne
16
Index Data Valid? 463 1 116 1 2 460 1 3 407 1 4 727 5 719 1 6 203 7 12 1 8 192 1
…
Virtual address: Physical address: Virtual page number Page offset Physical page number Page offset Page table:
17
Adapted from Operating System Concepts by Silberschatz, Galvin, and Gagne
18
19
20
21
1st-level “pointers” 2nd-level PTEs VPN[9:0] VPN[19:10] struct { union { int ppn, disk_block; } int is_valid, is_dirty; } PTE; struct { struct PTE ptes[1024]; } L2PT; struct L2PT *pt[1024]; int translate(int vpn) { struct L2PT *l2pt = pt[vpn>>10]; if (l2pt && l2pt->ptes[vpn&1023].is_valid) return l2pt->ptes[vpn&1023].ppn; } pt “root”
22
23
24
25
26
27
VPN PPN VPN PPN VPN PPN “tag” “data” PA VA VA VA VA
28
29
30
Memory reference Is in physical memory? Success Is page stored on disk? Load it, success Invalid reference, abort!
Y N N Y
Adapted from Operating System Concepts by Silberschatz, Galvin, and Gagne
Hardware Operating system
31
PA VA VA VA VA
32
PA PA VA VA PA PA
33
PA PA VA VA
34
doesn’t change IDX
1:0 [31:12]
[11:2]
1 1022 1023 2
VPN [31:16] POFS[15:0]
35
1:0 [31:12] IDX[11:2] VPN [31:16] [15:0]
36
37
38
38 Event Picoseconds ≈ Hardware/target Source
Average instruction time* 30 30 ps Intel Core i7 4770k (Haswell), 3.9GHz
https://en.wikipedia.org/wiki/Instructions_per_se condTime for light to traverse CPU core (~13mm) 44 40 ps Intel Core i7 4770k (Haswell), 3.9GHz
http://www.anandtech.com/show/7003/the- haswell-review-intel-core-i74770k-i54560k- tested/5Clock cycle (3.9GHz) 256 300 ps Intel Core i7 4770k (Haswell), 3.9GHz
MathMemory read: L1 hit 1,212 1 ns Intel i3-2120 (Sandy Bridge), 3.3 GHz
http://www.7-cpu.com/cpu/SandyBridge.htmlMemory read: L2 hit 3,636 4 ns Intel i3-2120 (Sandy Bridge), 3.3 GHz
http://www.7-cpu.com/cpu/SandyBridge.htmlMemory read: L3 hit 8,439 8 ns Intel i3-2120 (Sandy Bridge), 3.3 GHz
http://www.7-cpu.com/cpu/SandyBridge.htmlMemory read: DRAM 64,485 60 ns Intel i3-2120 (Sandy Bridge), 3.3 GHz
http://www.7-cpu.com/cpu/SandyBridge.htmlProcess context switch or system call 3,000,000 3 us Intel E5-2620 (Sandy Bridge), 2GHz
http://blog.tsunanet.net/2010/11/how-long-does- it-take-to-make-context.htmlStorage sequential read**, 4kB (SSD) 7,233,796 7 us SSD: Samsung 840 500GB
http://www.samsung.com/global/business/semicStorage sequential read**, 4kB (HDD) 65,104,167 70 us HDD: 2.5" 500GB 7200RPM
http://www.samsung.com/global/business/semicStorage random read, 4kB (SSD) 100,000,000 100 us SSD: Samsung 840 500GB
http://www.samsung.com/global/business/semicStorage random read, 4kB (HDD) 10,000,000,000 10 ms HDD: 2.5" 500GB 7200RPM
http://www.samsung.com/global/business/semicInternet latency, Raleigh home to NCSU (3 mi) 21,000,000,000 20 ms courses.ncsu.edu
PingInternet latency, Raleigh home to Chicago ISP (639 mi) 48,000,000,000 50 ms dls.net
PingInternet latency, Raleigh home to Luxembourg ISP (4182 mi) 108,000,000,000 100 ms eurodns.com
PingTime for light to travel to the moon (average) 1,348,333,333,333 1 s The moon
http://www.wolframalpha.com/input/?i=distance +to+the+moon* Based on Dhrystone, single core only, average time per instruction ** Based on sequential throughput, average time per block
40
41
Adapted from Operating System Concepts by Silberschatz, Galvin, and Gagne
42
43
44
4M x 2B 4M x 2B 4M x 2B 4M x 2B 1 2 3 4M x 2B f
== error data address
45
46