Memory Management and RMAP VM of 2.6 By A.R.Karthick )

Slides:



Advertisements
Similar presentations
X March C- Copyright Soft Test Inc. Yellow Black = Stored data | Yellow = Write cycle | Red = Read cycle March C- Fundamentals of.
Advertisements

CS 105 Tour of the Black Holes of Computing
Virtual Memory on x86. Virtual Memory Refresher Problems with using raw memory: – Isolation Protect system and programs from other programs Two programs.
Virtual Memory 1 Computer Organization II © McQuain Virtual Memory Use main memory as a cache for secondary (disk) storage – Managed jointly.
Virtual Memory In this lecture, slides from lecture 16 from the course Computer Architecture ECE 201 by Professor Mike Schulte are used with permission.
Virtual Memory Really this is in OS – but We need to see how the OS will interact with the HW Peer Instruction Lecture Materials for Computer Architecture.
SE-292 High Performance Computing
Virtual Storage SystemCS510 Computer ArchitecturesLecture Lecture 14 Virtual Storage System.
CMPE 421 Parallel Computer Architecture
1 CMPT 300 Introduction to Operating Systems Virtual Memory Sample Questions.
Virtual Memory. Hierarchy Cache Memory : Provide invisible speedup to main memory.
16.317: Microprocessor System Design I
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.
1 Memory Systems Virtual Memory Lecture 25 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
The Memory Hierarchy (Lectures #24) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization.
Memory Problems Prof. Sin-Min Lee Department of Mathematics and Computer Sciences.
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.
Computer Organization Cs 147 Prof. Lee Azita Keshmiri.
CS 140 Lecture Notes: Virtual MemorySlide 1 Load-Time Relocation Process 1 0 ∞ Process 3 Operating System Process 6.
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 24 Instructor: L.N. Bhuyan
CS 241 Section Week #12 (04/22/10).
Virtual Memory Main Memory Magnetic Disk Upper level Lower level.
CS 153 Design of Operating Systems Spring 2015 Final Review.
Address Translation Mechanism of 80386
Computer Architecture Lecture 28 Fasih ur Rehman.
CMP 301A Computer Architecture 1 Lecture 4. Outline zVirtual memory y Terminology y Page Table y Translation Lookaside Buffer (TLB)
IT253: Computer Organization
Virtual Memory Expanding Memory Multiple Concurrent Processes.
1 Recitation #9, Section F, , Sp 06 Virtual memory Reminders: Quiz today: virtual memory Shell Lab due Thursday TA: Jernej Barbic Modified from:
University of Amsterdam Computer Systems – virtual memory Arnoud Visser 1 Computer Systems Virtual Memory.
Virtual Memory Additional Slides Slide Source: Topics Address translation Accelerating translation with TLBs class12.ppt.
Chapter 91 Logical Address in Paging  Page size always chosen as a power of 2.  Example: if 16 bit addresses are used and page size = 1K, we need 10.
4.3 Virtual Memory. Virtual memory  Want to run programs (code+stack+data) larger than available memory.  Overlays programmer divides program into pieces.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Implementation.
CS2100 Computer Organisation Virtual Memory – Own reading only (AY2015/6) Semester 1.
Virtual Memory Ch. 8 & 9 Silberschatz Operating Systems Book.
Virtual Memory Review Goal: give illusion of a large memory Allow many processes to share single memory Strategy Break physical memory up into blocks (pages)
The Memory Hierarchy Lecture 31 20/07/2009Lecture 31_CA&O_Engr. Umbreen Sabir.
Memory Management & Virtual Memory. Hierarchy Cache Memory : Provide invisible speedup to main memory.
Virtual Memory (Section 9.3). The Need For Virtual Memory Many computers don’t have enough memory in RAM to accommodate all the programs a user wants.
CS 140 Lecture Notes: Virtual Memory
Virtual Memory Chapter 7.4.
Section 8 Address Translation March 10th, 2017 Taught by Joshua Don.
CS161 – Design and Architecture of Computer
Section 9: Virtual Memory (VM)
Section 9: Virtual Memory (VM)
Address Translation Mechanism of 80386
Memory Hierarchy Virtual Memory, Address Translation
CSCI206 - Computer Organization & Programming
CS 140 Lecture Notes: Virtual Memory
Figure 11.1 A basic personal computer system
Paging Lecture November 2018.
FIGURE 12-1 Memory Hierarchy
ECE 445 – Computer Organization
Page that info back into your memory!
CS 140 Lecture Notes: Virtual Memory
Virtual Memory.
Memory Systems CH008.
Introduction to the Pentium’s support for “virtual” memory
Translation Buffers (TLB’s)
Computer System Design Lecture 11
Translation Buffers (TLB’s)
CSC3050 – Computer Architecture
Recursive Page Table Lookup in the x86
Translation Buffers (TLBs)
CS 140 Lecture Notes: Virtual Memory
Review What are the advantages/disadvantages of pages versus segments?
4.3 Virtual Memory.
Memory Management & Virtual Memory
Presentation transcript:

Memory Management and RMAP VM of 2.6 By A.R.Karthick )

Memory Hierarchies L2 cache L1 cache RAM Hard Disk TIMETIME

Page Tables Define the virtual to physical mapping Page directory,page mid level directory,page table entry define the course of translation Example: PGD 10 bits PTE 10 BITS (PMD folded in 32 bit) | | > (0x00080c0f) pgd index(0) pte_index(1 << 7), pmd is folded to pgd

Page Table Entry Status Bits (PTE Entry) PAGE_PRESENT PAGE_RW PAGE_USER PAGE_RESERVED PAGE_ACCESSED PAGE_DIRTY INTERNAL_STATUS

Page Fault Processor Exception raised when there is a problem mapping the virtual address to physical address. Handled by do_page_fault in arch/i386/mm/fault.c. Write protection faults or COW faults map to do_wp_page. For pages in swap, do_swap_page is called. For pages not found, do_no_page is called that either faults in an anonymous zero page or an existing page. Page faults populate the LRU cache.

Page Replacement Algorithms Optimal Replacement Not possible Not Recently Used (NRU) Crude hack FIFO Inefficient Second Chance Better than above Clock Replacement Efficient than above

Page Replacement Algorithms LRU – Least Recently used replacement NFU – Not Frequently Used replacement Page Ageing based replacement Working Set algorithm based on locality of references per process Working Set based clock algorithms LRU with Ageing and Working Set algorithms are efficient to use and are commonly used

Page replacement handling in Linux Kernel Page Cache Pages are added to the Page cache for fast lookup. Page cache pages are hashed based on their address space and page index Inode or disk block pages, shared pages and anonymous pages form the page cache. Swap cached pages also part of the page cache represent the swapped pages. Anonymous pages enter the swap cache at swap-out time and shared pages enter when they become dirty.

LRU CACHE LRU cache is made up of per zone active lists and inactive lists. Per-CPU lru active and inactive page vectors make lru cache additions faster. These lists are populated during page faults and when page cached pages are accessed or referenced. kswapd is the page out kernel thread per node that balances the LRU cache and trickles out pages based on an approximation to LRU algorithm. Page stealing is performed on a page vector or performed in batches. Active state Inactive dirty state Inactive clean state Per-CPU cold pages

Zone Balancing Kswapd performs zone balancing based on pages_high, pages_low and pages_min Zone is considered balance with its free pages above pages_high The page out process takes a page by scanning inactive pages in batches. Batch page stealing scales well for large physical memory.

RMAP Maintains mapping of a page to a pte/virtual address Greatly speeds up the page unmap path without scanning the process virtual address space Unmapping of shared pages is greatly improved because of availability of pte mappings for shared pages Page faults are reduced because pte entries are unmapped only when required. Reduced search space during page replacement as only inactive pages are touched. Low overhead involved in adding reverse mapping during fork, page fault, mmap and exit paths.

RMAP struct pte_chain { unsigned long next_and_idx; pte_addr_t ptes[NRPTE]; }____cachelinealigned; next_and_idx field contains both the index to the next pte in the same chain or a pointer to the next pte chain,thus aiding in fast pte chaining. pte chains have free slots at the top or the head of the chain and additions happen from the tail. process mm_struct pointer is kept in the pages address space, that is used during swapout times.

VM-Overcommit Policies Commit more than available/actual memory space which includes the swap space to the process. Overcommit policies can be set through sysctl vm.overcommit_{memory,ratio} 0 indicates no overcommit 1 indicates overcommit totally. 2 indicates overcommit with overcommit_ratio on total ram pages plus total swap space pages. mmap,mprotect, munmap, brk, shared memory, affect overcommit.

References Primarily Linux Kernel Source Code 2.6 Towards an O(1) VM by Rik Van Riel – Proceedings of the Linux Symposium –Ottawa