Chapter 5 B. Large and Fast: Exploiting Memory Hierarchy

Similar documents
Virtual Memory. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

Chapter 5 (Part II) Large and Fast: Exploiting Memory Hierarchy. Baback Izadi Division of Engineering Programs

ECE331: Hardware Organization and Design

Chapter 5. Large and Fast: Exploiting Memory Hierarchy. Part II Virtual Memory

LECTURE 4: LARGE AND FAST: EXPLOITING MEMORY HIERARCHY

Virtual Memory. Patterson & Hennessey Chapter 5 ELEC 5200/6200 1

Chapter 5 Large and Fast: Exploiting Memory Hierarchy (Part 2)

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Computer Architecture Computer Science & Engineering. Chapter 5. Memory Hierachy BK TP.HCM

ECE 331 Hardware Organization and Design. UMass ECE Discussion 11 4/12/2018

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition. Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Memory Technology. Chapter 5. Principle of Locality. Chapter 5 Large and Fast: Exploiting Memory Hierarchy 1

HY225 Lecture 12: DRAM and Virtual Memory

Virtual Memory. Reading. Sections 5.4, 5.5, 5.6, 5.8, 5.10 (2) Lecture notes from MKP and S. Yalamanchili

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

COMPUTER ORGANIZATION AND DESIGN ARM

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. 5 th. Edition. Chapter 5. Large and Fast: Exploiting Memory Hierarchy

COMPUTER ORGANIZATION AND DESIGN

CS/ECE 3330 Computer Architecture. Chapter 5 Memory

V. Primary & Secondary Memory!

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

ECE331: Hardware Organization and Design

COEN-4730 Computer Architecture Lecture 3 Review of Caches and Virtual Memory

Chapter 5. Large and Fast: Exploiting Memory Hierarchy. Jiang Jiang

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

COMPUTER ORGANIZATION AND DESIGN

Memory. Principle of Locality. It is impossible to have memory that is both. We create an illusion for the programmer. Employ memory hierarchy

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Chapter 5B. Large and Fast: Exploiting Memory Hierarchy

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface

CSCI 402: Computer Architectures. Performance of Multilevel Cache

Chapter 5 C. Virtual machines

5. Memory Hierarchy Computer Architecture COMP SCI 2GA3 / SFWR ENG 2GA3. Emil Sekerinski, McMaster University, Fall Term 2015/16

Memory Hierarchy Y. K. Malaiya

Virtualization. Pradipta De

Computer Architecture Review. Jo, Heeseung

Lecture 21: Virtual Memory. Spring 2018 Jason Tang

Virtual Memory: From Address Translation to Demand Paging

EN1640: Design of Computing Systems Topic 06: Memory System

EN1640: Design of Computing Systems Topic 06: Memory System

Virtual Memory - Objectives

I, J A[I][J] / /4 8000/ I, J A(J, I) Chapter 5 Solutions S-3.

Virtual Memory Virtual memory first used to relive programmers from the burden of managing overlays.

Main Memory (Fig. 7.13) Main Memory

1. Creates the illusion of an address space much larger than the physical memory

Translation Buffers (TLB s)

Virtual Memory: From Address Translation to Demand Paging

Chapter Seven. Memories: Review. Exploiting Memory Hierarchy CACHE MEMORY AND VIRTUAL MEMORY

John Wawrzynek & Nick Weaver

COMPUTER ARCHITECTURE. Virtualization and Memory Hierarchy

Background. IBM sold expensive mainframes to large organizations. Monitor sits between one or more OSes and HW

ECE468 Computer Organization and Architecture. Virtual Memory

Virtual Memory Review. Page faults. Paging system summary (so far)

Computer Architecture A Quantitative Approach, Fifth Edition. Chapter 2. Memory Hierarchy Design. Copyright 2012, Elsevier Inc. All rights reserved.

LECTURE 12. Virtual Memory

Copyright 2012, Elsevier Inc. All rights reserved.

ECE4680 Computer Organization and Architecture. Virtual Memory

Virtualization and memory hierarchy

LECTURE 5: MEMORY HIERARCHY DESIGN

CPS104 Computer Organization and Programming Lecture 16: Virtual Memory. Robert Wagner

Copyright 2012, Elsevier Inc. All rights reserved.

Virtual Machines. Part 1: 54 years ago. Operating Systems In Depth VIII 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.

Computer Architecture. A Quantitative Approach, Fifth Edition. Chapter 2. Memory Hierarchy Design. Copyright 2012, Elsevier Inc. All rights reserved.

Computer Architecture. Lecture 8: Virtual Memory

Topic 18: Virtual Memory

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 24

Guerrilla 7: Virtual Memory, ECC, IO

CSE 120 Principles of Operating Systems Spring 2017

CS 350 Winter 2011 Current Topics: Virtual Machines + Solid State Drives

Address spaces and memory management

ECE232: Hardware Organization and Design

Embedded Systems Dr. Santanu Chaudhury Department of Electrical Engineering Indian Institute of Technology, Delhi

CS 61C: Great Ideas in Computer Architecture. Virtual Memory

Performance! (1/latency)! 1000! 100! 10! Capacity Access Time Cost. CPU Registers 100s Bytes <10s ns. Cache K Bytes ns 1-0.

CPS 104 Computer Organization and Programming Lecture 20: Virtual Memory

CSE Memory Hierarchy Design Ch. 5 (Hennessy and Patterson)

COSC 3406: COMPUTER ORGANIZATION

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. November 15, MIT Fall 2018 L20-1

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23

Agenda. CS 61C: Great Ideas in Computer Architecture. Virtual Memory II. Goals of Virtual Memory. Memory Hierarchy Requirements

COSC3330 Computer Architecture Lecture 20. Virtual Memory

Today: Computer System Overview (Stallings, chapter ) Next: Operating System Overview (Stallings, chapter ,

Computer Systems. Virtual Memory. Han, Hwansoo

24-vm.txt Mon Nov 21 22:13: Notes on Virtual Machines , Fall 2011 Carnegie Mellon University Randal E. Bryant.

Fast access ===> use map to find object. HW == SW ===> map is in HW or SW or combo. Extend range ===> longer, hierarchical names

Memory Hierarchy. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

virtual memory Page 1 CSE 361S Disk Disk

Virtual Machines. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Last 2 Classes: Introduction to Operating Systems & C++ tutorial. Today: OS and Computer Architecture

CSE 120 Principles of Operating Systems

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

Virtual Machines. To do. q VM over time q Implementation methods q Hardware features supporting VM q Next time: Midterm?

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 23

Processes and Virtual Memory Concepts

CS370 Operating Systems

Virtual Memory. Virtual Memory

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. April 12, 2018 L16-1

Fast access ===> use map to find object. HW == SW ===> map is in HW or SW or combo. Extend range ===> longer, hierarchical names

Transcription:

Chapter 5 B Large and Fast: Exploiting Memory Hierarchy

Dependability 5.5 Dependable Memory Hierarchy Chapter 6 Storage and Other I/O Topics 2

Dependability Service accomplishment Service delivered as specified Restoration Failure Fault: failure of a component May or may not lead to system failure 5.5 Dependable Memory Hierarchy Service interruption Deviation from specified service Chapter 6 Storage and Other I/O Topics 3

Dependability Measures Reliability: mean time to failure (MTTF) Service interruption: mean time to repair (MTTR) Mean time between failures MTBF = MTTF + MTTR Availability = MTTF / (MTTF + MTTR) Improving Availability Increase MTTF: fault avoidance, fault tolerance, fault forecasting Reduce MTTR: improved tools and processes for diagnosis and repair Chapter 6 Storage and Other I/O Topics 4

The Hamming SEC Code Hamming distance Number of bits that are different between two bit patterns Minimum distance = 2 provides single bit error detection E.g. parity code Minimum distance = 3 provides single error correction, 2 bit error detection Chapter 5 Large and Fast: Exploiting Memory Hierarchy 5

Encoding SEC To calculate Hamming code: Number bits from 1 on the left All bit positions that are a power 2 are parity bits Each parity bit checks certain data bits: Chapter 5 Large and Fast: Exploiting Memory Hierarchy 6

Decoding SEC Value of parity bits indicates which bits are in error Use numbering from encoding procedure E.g. Parity bits = 0000 indicates no error Parity bits = 1010 indicates bit 10 was flipped Chapter 5 Large and Fast: Exploiting Memory Hierarchy 7

Example Chapter 5 Large and Fast: Exploiting Memory Hierarchy 8

SEC/DEC Code Add an additional parity bit for the whole word (p n ) Make Hamming distance = 4 Decoding: Let H = SEC parity bits H even, p n even, no error H odd, p n odd, correctable single bit error H even, p n odd, error in p n bit H odd, p n even, double error occurred Note: ECC DRAM uses SEC/DEC with 8 bits protecting each 64 bits Chapter 5 Large and Fast: Exploiting Memory Hierarchy 9

Virtual Memory 5.7 Virtual Memory Chapter 5 Large and Fast: Exploiting Memory Hierarchy 10

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 memory Each gets a private virtual address space holding its frequently used code and data Protected from other programs CPU and OS translate virtual addresses to physical addresses VM block is called a page VM translation miss is called a page fault 5.7 Virtual Memory Chapter 5 Large and Fast: Exploiting Memory Hierarchy 11

Address Translation Fixed-size pages (e.g., 4K) Chapter 5 Large and Fast: Exploiting Memory Hierarchy 12

Page Fault Penalty On page fault, the page must be fetched from disk Takes millions of clock cycles Handled by OS code Try to minimize page fault rate Fully associative placement Smart replacement algorithms Chapter 5 Large and Fast: Exploiting Memory Hierarchy 13

Page Tables Stores placement information Array of page table entries, indexed by virtual page number Page table register in CPU points to page table in physical memory If page is present in memory PTE stores the physical page number Plus other status bits (referenced, dirty, ) If page is not present PTE can refer to location in swap space on disk Chapter 5 Large and Fast: Exploiting Memory Hierarchy 14

Translation Using a Page Table Chapter 5 Large and Fast: Exploiting Memory Hierarchy 15

Mapping Pages to Storage Chapter 5 Large and Fast: Exploiting Memory Hierarchy 16

Replacement and Writes To reduce page fault rate, prefer leastrecently used (LRU) replacement Reference bit (aka use bit) in PTE set to 1 on access to page Periodically cleared to 0 by OS A page with reference bit = 0 has not been used recently Disk writes take millions of cycles Block at once, not individual locations Write through is impractical Use write-back Dirty bit in PTE set when page is written Chapter 5 Large and Fast: Exploiting Memory Hierarchy 17

Fast Translation Using a TLB Address translation would appear to require extra memory references One to access the PTE Then the actual memory access But access to page tables has good locality So use a fast cache of PTEs within the CPU Called a Translation Look-aside Buffer (TLB) Typical: 16 512 PTEs, 0.5 1 cycle for hit, 10 100 cycles for miss, 0.01% 1% miss rate Misses could be handled by hardware or software Chapter 5 Large and Fast: Exploiting Memory Hierarchy 18

Fast Translation Using a TLB Chapter 5 Large and Fast: Exploiting Memory Hierarchy 19

TLB Misses If page is in memory Load the PTE from memory and retry Could be handled in hardware Can get complex for more complicated page table structures Or in software Raise a special exception, with optimized handler If page is not in memory (page fault) OS handles fetching the page and updating the page table Then restart the faulting instruction Chapter 5 Large and Fast: Exploiting Memory Hierarchy 20

Memory Protection Different tasks can share parts of their virtual address spaces But need to protect against errant access Requires OS assistance Hardware support for OS protection Privileged supervisor mode (aka kernel mode) Privileged instructions Page tables and other state information only accessible in supervisor mode System call exception (e.g., syscall in MIPS) Chapter 5 Large and Fast: Exploiting Memory Hierarchy 24

The Memory Hierarchy The BIG Picture Common principles apply at all levels of the memory hierarchy Based on notions of caching At each level in the hierarchy Block placement Finding a block Replacement on a miss Write policy 5.8 A Common Framework for Memory Hierarchies Chapter 5 Large and Fast: Exploiting Memory Hierarchy 25

Multilevel On-Chip Caches Chapter 5 Large and Fast: Exploiting Memory Hierarchy 42 5.13 The ARM Cortex-A8 and Intel Core i7 Memory Hierarchies

2-Level TLB Organization Chapter 5 Large and Fast: Exploiting Memory Hierarchy 43

Concluding Remarks Fast memories are small, large memories are slow We really want fast, large memories Caching gives this illusion Principle of locality Programs use a small part of their memory space frequently Memory hierarchy L1 cache L2 cache DRAM memory disk Memory system design is critical for multiprocessors 5.16 Concluding Remarks Chapter 5 Large and Fast: Exploiting Memory Hierarchy 49

Virtual Machines 5.6 Virtual Machines Chapter 5 Large and Fast: Exploiting Memory Hierarchy 50

Virtual Machines Host computer emulates guest operating system and machine resources Improved isolation of multiple guests Avoids security and reliability problems Aids sharing of resources Virtualization has some performance impact Feasible with modern high-performance comptuers Examples IBM VM/370 (1970s technology!) VMWare Microsoft Virtual PC 5.6 Virtual Machines Chapter 5 Large and Fast: Exploiting Memory Hierarchy 51

Virtual Machine Monitor Maps virtual resources to physical resources Memory, I/O devices, CPUs Guest code runs on native machine in user mode Traps to VMM on privileged instructions and access to protected resources Guest OS may be different from host OS VMM handles real I/O devices Emulates generic virtual I/O devices for guest Chapter 5 Large and Fast: Exploiting Memory Hierarchy 52

Virtual Machine Monitor (Hypervisor) Chapter 5 Large and Fast: Exploiting Memory Hierarchy 53

Example: Timer Virtualization In native machine, on timer interrupt OS suspends current process, handles interrupt, selects and resumes next process With Virtual Machine Monitor VMM suspends current VM, handles interrupt, selects and resumes next VM If a VM requires timer interrupts VMM emulates a virtual timer Emulates interrupt for VM when physical timer interrupt occurs Chapter 5 Large and Fast: Exploiting Memory Hierarchy 54

Instruction Set Support User and System modes Privileged instructions only available in system mode Trap to system if executed in user mode All physical resources only accessible using privileged instructions Including page tables, interrupt controls, I/O registers Renaissance of virtualization support Current ISAs (e.g., x86) adapting Chapter 5 Large and Fast: Exploiting Memory Hierarchy 55