Lecture 19: Virtual Memory

Slides:



Advertisements
Similar presentations
Virtual Memory In this lecture, slides from lecture 16 from the course Computer Architecture ECE 201 by Professor Mike Schulte are used with permission.
Advertisements

1 Lecture 13: Cache and Virtual Memroy Review Cache optimization approaches, cache miss classification, Adapted from UCB CS252 S01.
COMP381 by M. Hamdi 1 Virtual Memory. COMP381 by M. Hamdi 2 Virtual Memory: The Problem For example: MIPS64 is a 64-bit architecture allowing an address.
Virtual Memory Chapter 18 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer,  S. Dandamudi.
Computer Organization CS224 Fall 2012 Lesson 44. Virtual Memory  Use main memory as a “cache” for secondary (disk) storage l Managed jointly by CPU hardware.
Lecture 34: Chapter 5 Today’s topic –Virtual Memories 1.
CSIE30300 Computer Architecture Unit 10: Virtual Memory Hsin-Chou Chi [Adapted from material by and
Virtual Memory Hardware Support
CSC 4250 Computer Architectures December 8, 2006 Chapter 5. Memory Hierarchy.
Caching IV Andreas Klappenecker CPSC321 Computer Architecture.
Memory/Storage Architecture Lab Computer Architecture Virtual Memory.
The Memory Hierarchy (Lectures #24) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization.
Virtual Memory Adapted from lecture notes of Dr. Patterson and Dr. Kubiatowicz of UC Berkeley.
Spring 2003CSE P5481 Introduction Why memory subsystem design is important CPU speeds increase 55% per year DRAM speeds increase 3% per year rate of increase.
CSCE 212 Chapter 7 Memory Hierarchy Instructor: Jason D. Bakos.
S.1 Review: The Memory Hierarchy Increasing distance from the processor in access time L1$ L2$ Main Memory Secondary Memory Processor (Relative) size of.
Review CPSC 321 Andreas Klappenecker Announcements Tuesday, November 30, midterm exam.
1 Chapter Seven Large and Fast: Exploiting Memory Hierarchy.
The Memory Hierarchy II CPSC 321 Andreas Klappenecker.
Technical University of Lodz Department of Microelectronics and Computer Science Elements of high performance microprocessor architecture Virtual memory.
Virtual Memory. Why do we need VM? Program address space: 0 – 2^32 bytes –4GB of space Physical memory available –256MB or so Multiprogramming systems.
Virtual Memory and Paging J. Nelson Amaral. Large Data Sets Size of address space: – 32-bit machines: 2 32 = 4 GB – 64-bit machines: 2 64 = a huge number.
©UCB CS 162 Ch 7: Virtual Memory LECTURE 13 Instructor: L.N. Bhuyan
1 SRAM: –value is stored on a pair of inverting gates –very fast but takes up more space than DRAM (4 to 6 transistors) DRAM: –value is stored as a charge.
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy (Part II)
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 24 Instructor: L.N. Bhuyan
Lecture 33: Chapter 5 Today’s topic –Cache Replacement Algorithms –Multi-level Caches –Virtual Memories 1.
Topics covered: Memory subsystem CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Computer Architecture Lecture 28 Fasih ur Rehman.
CSE431 L22 TLBs.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 22. Virtual Memory Hardware Support Mary Jane Irwin (
Lecture 15: Virtual Memory EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer Engineering Spring 2014, Dr.
1  2004 Morgan Kaufmann Publishers Multilevel cache Used to reduce miss penalty to main memory First level designed –to reduce hit time –to be of small.
July 30, 2001Systems Architecture II1 Systems Architecture II (CS ) Lecture 8: Exploiting Memory Hierarchy: Virtual Memory * Jeremy R. Johnson Monday.
The Memory Hierarchy 21/05/2009Lecture 32_CA&O_Engr Umbreen Sabir.
Lecture 9: Memory Hierarchy Virtual Memory Kai Bu
1 Virtual Memory Main memory can act as a cache for the secondary storage (disk) Advantages: –illusion of having more physical memory –program relocation.
1  1998 Morgan Kaufmann Publishers Recap: Memory Hierarchy of a Modern Computer System By taking advantage of the principle of locality: –Present the.
Virtual Memory. Virtual Memory: Topics Why virtual memory? Virtual to physical address translation Page Table Translation Lookaside Buffer (TLB)
2015/11/26\course\cpeg323-08F\Topic7e1 Virtual Memory.
Introduction: Memory Management 2 Ideally programmers want memory that is large fast non volatile Memory hierarchy small amount of fast, expensive memory.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
1 Chapter Seven CACHE MEMORY AND VIRTUAL MEMORY. 2 SRAM: –value is stored on a pair of inverting gates –very fast but takes up more space than DRAM (4.
1  2004 Morgan Kaufmann Publishers Chapter Seven Memory Hierarchy-3 by Patterson.
CS2100 Computer Organisation Virtual Memory – Own reading only (AY2015/6) Semester 1.
CS.305 Computer Architecture Memory: Virtual Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from slides kindly made available.
Virtual Memory Ch. 8 & 9 Silberschatz Operating Systems Book.
LECTURE 12 Virtual Memory. VIRTUAL MEMORY Just as a cache can provide fast, easy access to recently-used code and data, main memory acts as a “cache”
1 Chapter Seven. 2 SRAM: –value is stored on a pair of inverting gates –very fast but takes up more space than DRAM (4 to 6 transistors) DRAM: –value.
Virtual Memory 1 Computer Organization II © McQuain Virtual Memory Use main memory as a “cache” for secondary (disk) storage – Managed jointly.
High Performance Computing1 High Performance Computing (CS 680) Lecture 2a: Overview of High Performance Processors * Jeremy R. Johnson *This lecture was.
3/1/2002CSE Virtual Memory Virtual Memory CPU On-chip cache Off-chip cache DRAM memory Disk memory Note: Some of the material in this lecture are.
CS203 – Advanced Computer Architecture Virtual Memory.
Memory Management memory hierarchy programs exhibit locality of reference - non-uniform reference patterns temporal locality - a program that references.
Virtual Memory Chapter 8.
CS161 – Design and Architecture of Computer
Memory Hierarchy Ideal memory is fast, large, and inexpensive
ECE232: Hardware Organization and Design
Memory COMPUTER ARCHITECTURE
CS161 – Design and Architecture of Computer
Lecture 12 Virtual Memory.
CS 704 Advanced Computer Architecture
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
Part V Memory System Design
CMSC 611: Advanced Computer Architecture
Lecture 29: Virtual Memory-Address Translation
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Virtual Memory Overcoming main memory size limitation
CSC3050 – Computer Architecture
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
Presentation transcript:

Lecture 19: Virtual Memory Virtual Memory concept, Virtual-physical translation, page table, TLB, Alpha 21264 memory hierarchy This lecture will cover sections 1.1-1.4: introduction, application, technology trends, cost and price. Adapted from UC Berkeley CS252 S01

Virtual Memory Virtual memory (VM) allows programs to have the illusion of a very large memory that is not limited by physical memory size Make main memory (DRAM) acts like a cache for secondary storage (magnetic disk) Otherwise, application programmers have to move data in/out main memory That’s how virtual memory was first proposed Virtual memory also provides the following functions Allowing multiple processes share the physical memory in multiprogramming environment Providing protection for processes (compare Intel 8086: without VM applications can overwrite OS kernel) Facilitating program relocation in physical memory space

VM Example

Virtual Memory and Cache VM address translation a provides a mapping from the virtual address of the processor to the physical address in main memory and secondary storage. Cache terms vs. VM terms Cache block => page Cache Miss => page fault Tasks of hardware and OS TLB does fast address translations OS handles less frequently events: page fault TLB miss (when software approach is used)

Virtual Memory and Cache

4 Qs for Virtual Memory Q1: Where can a block be placed in the upper level? Miss penalty for virtual memory is very high => Full associativity is desirable (so allow blocks to be placed anywhere in the memory) Have software determine the location while accessing disk (10M cycles enough to do sophisticated replacement) Q2: How is a block found if it is in the upper level? Address divided into page number and page offset Page table and translation buffer used for address translation Q: why fully associativity does not affect hit time?

4 Qs for Virtual Memory Q3: Which block should be replaced on a miss? Want to reduce miss rate & can handle in software Least Recently Used typically used A typical approximation of LRU Hardware set reference bits OS record reference bits and clear them periodically OS selects a page among least-recently referenced for replacement Q4: What happens on a write? Writing to disk is very expensive Use a write-back strategy

Virtual and Physical Addresses A virtual address consists of a virtual page number and a page offset. The virtual page number gets translated to a physical page number. The page offset is not changed Virtual Page Number Page offset Physical Page Number Translation Virtual Address Physical Address 36 bits 33 bits 12 bits

Address Translation Via Page Table Assume the access hits in main memory

Address Translation with Page Tables A page table translates a virtual page number into a physical page number A page table register indicates the start of the page table. The virtual page number is used as an index into the page table that contains The physical page number A valid bit that indicates if the page is present in main memory A dirty bit to indicate if the page has been written Protection information about the page (read only, read/write, etc.) Since page tables contain a mapping for every virtual page, no tags are required (how to compare it with cache?) Page table access is slow; we will see the solution

Page Table Diagram

Accessing Main Memory or Disk Valit bit being zero means the page is not in main memory Then a page fault occurs, and the missing page is read in from disk.

How Large Is Page Table? Suppose 48-bit virtual address 41-bit physical address 8 KB pages => 13 bit page offset Each page table entry is 8 bytes How large is the page table? Virtual page number = 48 - 13 = 25 bytes Number of entries = number of pages = 225 = 32M Total size = number of entries x bytes/entry = 32M x 8B = 256 Mbytes Each process needs its own page table Page tables have to be very large, thus must be stored in main page or even paged, resulting in slow access We need techniques to reduce page table size

TLB: Improving Page Table Access Cannot afford accessing page table for every access include cache hits (then cache itself makes no sense) Again, use cache to speed up accesses to page table! (cache for cache?) TLB is translation lookaside buffer storing frequently accessed page table entry A TLB entry is like a cache entry Tag holds portions of virtual address Data portion holds physical page number, protection field, valid bit, use bit, and dirty bit (like in page table entry) Usually fully associative or highly set associative Usually 64 or 128 entries Access page table only for TLB misses

TLB Characteristics The following are characteristics of TLBs TLB size : 32 to 4,096 entries Block size : 1 or 2 page table entries (4 or 8 bytes each) Hit time: 0.5 to 1 clock cycle Miss penalty: 10 to 30 clock cycles (go to page table) Miss rate: 0.01% to 0.1% Associative : Fully associative or set associative Write policy : Write back (replace infrequently)

Alpha 21264 Data TLB 128 entries, fully associative ASN (like PID) to avoid flushing Also check protection

Determine Page Size Larger Size Comments Page table size  Inversely proportional Fast L1 cache hit  L1 cache can be larger I/O utilization  Longer burst transfer TLB hit rate  Increasing TLB coverage Storage efficiency  Reducing fragmentation I/O efficiency  Unnecessary data transfer Process start-up  Small processes are popular Most commonly used size: 4KB or 8KB Hardware may support a range of page sizes OS selects the best one(s) for its purpose

Alpha 21264 TLB Access Virtual indexed Physically tagged Physically indexed Physically tagged

Alpha 21264 Virtual Memory Combining segmentation and paging Segmentation: variable-size memory space range, usually defined by a base register and a limit field Segmentation assign meanings to address spaces, and reduce address space that needs paging (reducing page table size) Paging is used on the address space of each segment Three segments in Alpha kseg: reserved for OS kernel, not VM management seg0: virtual address accessible to user process seg1: virtual address accessible to OS kernel

Two Viewpoints of Virtual Memory Application programs Sees a large, flat memory space Assumes fast access to every place Hardware/OS hide the complexity OS Kernel Manages multiple process spaces Reserves direct accesses to some portions of physical memory May access physical memory, its own virtual memory, and virtual memory of the current process Hardware facilitates fast VM accesses, and OS manages slow, less frequent events

Alpha 21264 Page Table Page table access on 10-bit 13-bit 1024 8B PTEs Page table access on TLB miss managed by software 28-bit 13-bit

Memory Protection Memory protection: preventing unauthorized accesses to process and kernel memory Memory protection implementation: User programs can only access through virtual memory PTE entry contains protection bits to allow shared but protected accesses Protection fields in Alpha Valid, user read enable, kernel read enable, user write enable, and kernel write enable

Memory Hierarchy Example: Alpha 21264 in AlphaServer ES40 L1 instruction cache: 2-way, 64KB, 64-byte block, Virtually indexed and tagged Use way prediction and line prediction to allow instruction fetching Inst prefetcher: store four prefetched instructions, accessed before L2 cache L1 data cache: 2-way, 64KB, 64-byte block, Virtually indexed, physically tagged, write-through Victim buffer: 8-entry, checked before L2 access L2 unified cache: 1-way 1MB to 16MB, off-chip, write-back; Allow critical-word transfer to L1 cache, transfers 16B per 2.25ns TLB: 128-entry fully associative for inst and data (each) ES40: L1 miss penalty 22ns, L2 130 ns; up to 32GB memory; 256-bit memory buses (64-bit into processor) Read 5.13 for more details