ECE 598 Advanced Operating Systems Lecture 14

Similar documents
ECE 571 Advanced Microprocessor-Based Design Lecture 12

ECE 571 Advanced Microprocessor-Based Design Lecture 13

ECE 598 Advanced Operating Systems Lecture 14

Lecture 21: Virtual Memory. Spring 2018 Jason Tang

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

Virtual Memory: From Address Translation to Demand Paging

Virtual Memory. CS61, Lecture 15. Prof. Stephen Chong October 20, 2011

CS162 Operating Systems and Systems Programming Lecture 12. Address Translation. Page 1

Memory Management. Dr. Yingwu Zhu

Chapter 8. Virtual Memory

Address spaces and memory management

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

CSE 451: Operating Systems Winter Page Table Management, TLBs and Other Pragmatics. Gary Kimura

CS5460: Operating Systems Lecture 14: Memory Management (Chapter 8)

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management

CSE 120 Principles of Operating Systems

Operating Systems. 09. Memory Management Part 1. Paul Krzyzanowski. Rutgers University. Spring 2015

CIS Operating Systems Memory Management Cache and Demand Paging. Professor Qiang Zeng Spring 2018

CPS 104 Computer Organization and Programming Lecture 20: Virtual Memory

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

CIS Operating Systems Memory Management Cache. Professor Qiang Zeng Fall 2017

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

Operating Systems. Paging... Memory Management 2 Overview. Lecture 6 Memory management 2. Paging (contd.)

Virtual Memory: From Address Translation to Demand Paging

CS162 - Operating Systems and Systems Programming. Address Translation => Paging"

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Virtual Memory. Kevin Webb Swarthmore College March 8, 2018

Recall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory

Multi-level Translation. CS 537 Lecture 9 Paging. Example two-level page table. Multi-level Translation Analysis

Memory: Page Table Structure. CSSE 332 Operating Systems Rose-Hulman Institute of Technology

CIS Operating Systems Memory Management Cache. Professor Qiang Zeng Fall 2015

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

CS 318 Principles of Operating Systems

Learning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory.

Learning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory.

18-447: Computer Architecture Lecture 18: Virtual Memory III. Yoongu Kim Carnegie Mellon University Spring 2013, 3/1

Page 1. Review: Address Segmentation " Review: Address Segmentation " Review: Address Segmentation "

Basic Memory Management

Chapter 8 Memory Management

Operating Systems. Operating Systems Sina Meraji U of T

ECE331: Hardware Organization and Design

COS 318: Operating Systems. Virtual Memory and Address Translation

Memory management. Last modified: Adaptation of Silberschatz, Galvin, Gagne slides for the textbook Applied Operating Systems Concepts

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

COSC3330 Computer Architecture Lecture 20. Virtual Memory

PROCESS VIRTUAL MEMORY PART 2. CS124 Operating Systems Winter , Lecture 19

Modern Virtual Memory Systems. Modern Virtual Memory Systems

Virtual Memory. Virtual Memory

Chapter 8: Memory-Management Strategies

Virtual to physical address translation

virtual memory Page 1 CSE 361S Disk Disk

DAT (cont d) Assume a page size of 256 bytes. physical addresses. Note: Virtual address (page #) is not stored, but is used as an index into the table

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

ADDRESS TRANSLATION AND TLB

Virtual Memory. Motivations for VM Address translation Accelerating translation with TLBs

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 23

Today: Segmentation. Last Class: Paging. Costs of Using The TLB. The Translation Look-aside Buffer (TLB)

ADDRESS TRANSLATION AND TLB

CHAPTER 8 - MEMORY MANAGEMENT STRATEGIES

Chapter 8: Main Memory

CS 333 Introduction to Operating Systems. Class 11 Virtual Memory (1) Jonathan Walpole Computer Science Portland State University

Computer Systems. Virtual Memory. Han, Hwansoo

Address Translation. Tore Larsen Material developed by: Kai Li, Princeton University

Chapter 8: Main Memory. Operating System Concepts 9 th Edition

CSE 153 Design of Operating Systems

Lecture 13: Address Translation

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

Topics: Memory Management (SGG, Chapter 08) 8.1, 8.2, 8.3, 8.5, 8.6 CS 3733 Operating Systems

Lecture 12: Demand Paging

CS 3733 Operating Systems:

Multi-Process Systems: Memory (2) Memory & paging structures: free frames. Memory & paging structures. Physical memory

Main Memory: Address Translation

EECS 470. Lecture 16 Virtual Memory. Fall 2018 Jon Beaumont

Processes and Virtual Memory Concepts

Operating Systems (1DT020 & 1TT802) Lecture 9 Memory Management : Demand paging & page replacement. Léon Mugwaneza

Motivations for Virtual Memory Virtual Memory Oct. 29, Why VM Works? Motivation #1: DRAM a Cache for Disk

Chapter 3 - Memory Management

CIS Operating Systems Memory Management Address Translation for Paging. Professor Qiang Zeng Spring 2018

HY225 Lecture 12: DRAM and Virtual Memory

CSE 120 Principles of Operating Systems Spring 2017

Random-Access Memory (RAM) Systemprogrammering 2007 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics

John Wawrzynek & Nick Weaver

Reducing Hit Times. Critical Influence on cycle-time or CPI. small is always faster and can be put on chip

Virtual Memory Oct. 29, 2002

Memory Management. Goals of Memory Management. Mechanism. Policies

Random-Access Memory (RAM) Systemprogrammering 2009 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics! The memory hierarchy

Memory Management. To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time.

Virtual Memory. CS 3410 Computer System Organization & Programming

virtual memory. March 23, Levels in Memory Hierarchy. DRAM vs. SRAM as a Cache. Page 1. Motivation #1: DRAM a Cache for Disk

CS252 S05. Main memory management. Memory hardware. The scale of things. Memory hardware (cont.) Bottleneck

CS 261 Fall Mike Lam, Professor. Virtual Memory

Chapter 8: Main Memory

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23

Learning to Play Well With Others

CS 152 Computer Architecture and Engineering. Lecture 11 - Virtual Memory and Caches

CHAPTER 8: MEMORY MANAGEMENT. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

3/3/2014! Anthony D. Joseph!!CS162! UCB Spring 2014!

Transcription:

ECE 598 Advanced Operating Systems Lecture 14 Vince Weaver http://www.eece.maine.edu/~vweaver vincent.weaver@maine.edu 22 March 2016

Announcements 1

Got a Pi3 over break Pi3 Notes Very impressive performance, but under extreme load (Linpack) can overheat and give wrong results Not very suitable for this class; the ACT LED is now behind the GPU/i2c/GPIO-expander. By default the Bluetooth device steals the good serial port. Plus other issues. 2

Hand Back Midterms 3

HW6 Review 61 for divider, actually nice What do you mean by 1Hz? 4

Virtual Memory Redux Original purpose was to give the illusion of more main memory than available, with disk as backing store. Give each process own linear view of memory. Demand paging (no swapping out whole processes). Execution of processes only partly in memory, effectively a cache. Memory protection 5

Diagram Virtual Process 1 Virtual Process 2 Kernel Kernel Stack Stack Heap BSS Data Text Physical RAM Heap BSS Data Text 6

Memory Management Unit Can run without MMU. There s even MMU-less Linux. How do you keep processes separate? Very carefully... 7

Page Table Collection of Page Table Entries (PTE) Some common components: ID of owner, Virtual Page Number, valid bit, location of page (memory, disk, etc), protection info (read only, etc), page is dirty, age (how recent updated, for LRU) 8

Hierarchical Page Tables With 4GB memory and 4kb pages, you have 1 Million pages per process. If each has 4-byte PTE then 4MB of page tables per-process. Too big. It is likely each process does not use all 4GB at once. (sparse) So put page tables in swappable virtual memory themselves! 4MB page table is 1024 pages which can be mapped in 1 4KB page. 9

Hierarchical Page Table Diagram Physical Memory Virtual Address 10bits 10bits 12bits 4MB Page Table 4kB page tables Page Table Base Address (Stored in a register) 10

Hierarchical Page Table Diagram 32-bit x86 chips have hardware 2-level page tables ARM 2-level page tables 11

Inverted Page Table How to handle larger 64-bit address spaces? Can add more levels of page tables (4? 5?) but that becomes very slow Can use hash to find page. Better best case performance, can perform poorly if hash algorithm has lots of aliasing. 12

Inverted Page Table Diagram Physical Memory Virtual Address Page Tables HASH hit alias re hash 13

Walking the Page Table Can be walked in Hardware or Software Hardware is more common Early RISC machines would do it in Software. Can be slow. Has complications: what if the page-walking code was swapped out? 14

TLB Translation Lookaside Buffer (Lookaside Buffer is an obsolete term meaning cache) Caches page tables Much faster than doing a page-table walk. Historically fully associative, recently multi-level multiway TLB shootdown when change a setting on a mapping 15

and TLB invalidated on all other processors 16

Flushing the TLB May need to do this on context switch if doesn t store ASID or ASIDs run out (ASID=Address Space ID) Sometimes called a TLB Shootdown Hurts performance as the TLB gradually refills Avoiding this is why the top part is mapped to kernel under Linux 17

What happens on a memory access If in TLB, not a problem, right page fetched from physical memory, TLB updated If not in TLB, then the page tables are walked It no physical mapping in page table, then page fault happens 18

What happens on a page fault Walk the page table and see if the page is valid and there minor page is already in memory, just need to point a PTE at it. For example, shared memory, shared libraries, etc. major page needs to be created or brought in from disk. Demand paging. Needs to find room in physical memory. If no free space 19

available, needs to kick something out. Disk-backed (and not dirty) just discarded. Disk-backed and dirty, written back. Memory can be paged to disk. Eventually can OOM. Memory is then loaded, or zeroed, and PTE updated. Can it be shared? (zero page) invalid segfault 20

Uses of VM in an operating system Process separation, security Each process own view of memory Kernel mapped into each process address space Auto-growing stack zero page? Memory overcommit 21

Demand paging Copy-on-write with fork 22

What happens on a fork? Do you actually copy all of memory? Why would that be bad? (slow, also often exec() right away) Page table marked read-only, then shared Only if writes happen, take page fault, then copy made Copy-on-write (COW) 23

Large Pages Another way to avoid problems with 64-bit address space Larger page size (64kB? 1MB? 2MB? 2GB?) Less granularity. Potentially waste space Fewer TLB entries needed to map large data structures Compromise: multiple page sizes. Complicate O/S and hardware. OS have to find free blocks of contiguous memory when allocating large page. 24

Transparent usage? Transparent Huge Pages? Alternative to making people using special interfaces to allocate. 25

Having Larger Physical than Virtual Address Space 32-bit processors cannot address more than 4GB x86 hit this problem a while ago, ARM just now Real solution is to move to 64-bit As a hack, can include extra bits in page tables, address more memory (though still limited to 4GB per-process) Linus Torvalds hates this. 26

Hit an upper limit around 16-32GB because entire low 4GB of kernel addressable memory fills with page tables 27

ARM 1176 (ARMv6) MMU See Chapter 6 of the ARM1176 Technical Reference Manual http://infocenter.arm.com/help/topic/ com.arm.doc.ddi0301h/ddi0301h_arm1176jzfs_r0p7_ trm.pdf page sizes: 4KB, 64KB, 1MB, and 16MB you can specify access permissions for 64KB large pages and 4KB small pages separately (Subpages) micro-tlb 28

one 64-entry unified TLB and a lockdown region of eight entries you can mark entries as a global mapping, or associated with a specific application space identifier to eliminate the requirement for TLB flushes on most context switches access permissions extended to enable Privileged readonly and Privileged or User read-only modes to be simultaneously supported hardware page table walks 29

separate Secure and Non-secure entries and page tables Small fast microtlb. 1 cycle. Has ASID Larger slower main TLB, 64-entry 2-way Enable MMU by writing to special register in CP15 30

ARM 1176 (ARMv6) Caches L1 instruction cache (32kB?) L1 data cache (32kB?). Aliasing if VM enabled (bits 12:13). Need to do page coloring, only use 4kB pages, or limit cache size to 16KB TCM (tighly coupled memory) small area of up to 32kb that you can map to arbitrary page location. Fast, cache speeds. Useful for things like FIQ handlers in real time systems. 31