CSE 451 Autumn 2003 November 13 Section.

Slides:



Advertisements
Similar presentations
Chapter 4 Memory Management Basic memory management Swapping
Advertisements

The Linux Kernel: Memory Management
Memory Management in Linux (Chap. 8 in Understanding the Linux Kernel)
Kernel memory allocation
Memory management.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 13: Main Memory (Chapter 8)
Memory/Storage Architecture Lab Computer Architecture Virtual Memory.
Linux Vs. Windows NT Memory Management Hitesh Kumar
1 Lecture 14: Virtual Memory Topics: virtual memory (Section 5.4) Reminders: midterm begins at 9am, ends at 10:40am.
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
CSI 400/500 Operating Systems Spring 2009 Lecture #9 – Paging and Segmentation in Virtual Memory Monday, March 2 nd and Wednesday, March 4 th, 2009.
1 CSE451 – Section 7. 2 Usual stuff Project 3 will be due Monday the 27 th Experiment design to TAs: By midnight on Sunday the 19th Today: Project.
1 Memory Management in Representative Operating Systems.
1 Usual stuff Project 2 back today Average: 66.8/80 Today: Project 3 A few project 2 comments.
Memory Management in Windows and Linux &. Windows Memory Management Virtual memory manager (VMM) –Executive component responsible for managing memory.
Operating System Chapter 7. Memory Management Lynn Choi School of Electrical Engineering.
Lecture Topics: 11/17 Page tables TLBs Virtual memory flat page tables
1 Lecture 16: Virtual Memory Topics: virtual memory, improving TLB performance (Sections )
Lec 7aOperating Systems1 Operating Systems Lecture 7a: Linux Memory Manager William M. Mongan.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Implementation.
10.1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples.
COS 318: Operating Systems Virtual Memory Design Issues.
W4118 Operating Systems Instructor: Junfeng Yang.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
Linux 2.6 Memory Management Joseph Garvin. Why do we care? Without keeping multiple process in memory at once, we loose all the hard work we just did.
Last lecture: VM Implementation
CS161 – Design and Architecture of Computer
Lecture 11 Virtual Memory
Chapter 2: The Linux System Part 4
Virtual Memory Chapter 7.4.
CS161 – Design and Architecture of Computer
A Real Problem What if you wanted to run a program that needs more memory than you have? September 11, 2018.
Chapter 9: Virtual Memory – Part I
CS703 - Advanced Operating Systems
Outline Paging Swapping and demand paging Virtual memory.
Chapter 9: Virtual Memory
Review.
Main Memory Management
CSE 153 Design of Operating Systems Winter 2018
Lecture 28: Virtual Memory-Address Translation
Virtual Memory: Concepts /18-213/14-513/15-513: Introduction to Computer Systems 17th Lecture, October 23, 2018.
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
Evolution in Memory Management Techniques
Chapter 9: Virtual-Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Reminders Homework 4 & project 2 Midterm on Monday, November 8
CSE 451: Operating Systems Autumn 2005 Memory Management
Operating System Chapter 7. Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Contents Memory types & memory hierarchy Virtual memory (VM)
CSE451 Virtual Memory Paging Autumn 2002
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Semester Review Brian Kocoloski
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Computer Architecture
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 153 Design of Operating Systems Winter 2019
CSE 471 Autumn 1998 Virtual memory
CS703 - Advanced Operating Systems
Lecture 9: Caching and Demand-Paged Virtual Memory
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.
Buddy Allocation CS 161: Lecture 5 2/11/19.
COMP755 Advanced Operating Systems
Cache writes and examples
Chapter 8 & 9 Main Memory and Virtual Memory
CSE 542: Operating Systems
Presentation transcript:

CSE 451 Autumn 2003 November 13 Section

Questions from Lecture?

Questions from the Project?

Questions from the Exam?

Questions from Homework? 9.11: what is the effect of have two entries in a page table point at the same physical page not two entries in two page tables Aliasing Same memory shows up twice Changing a byte in one view changes the other Copying Can implement copy by just remapping Need to make both copies read-only, do copy when one changes to get copy semantics

Memory Protection 9.9: How do operating systems prevent processes from seeing other memory? Common answer: valid/invalid bit Correct answer: Every address a process uses is translated by the page table A process has no language to talk about memory other than its own How can we implement this? Share a physical page between two PTEs Provide a system call to read/write memory in other processes

Project 3 - Virtual Memory Experiments Have a hypothesis “Big pages are better” “Algorithm y is better” “Prefetching will reduce the number of page faults” “If we understand why x happens, we can fix it”

Running experiments Two steps Control: what is the baseline? What happens with existing page sizes / page replacement algorithms / no prefeching New test: what happens with the new system Try to change just one aspect of the system to isolate the difference

Some ideas What is the ideal page size for this trace under different amount of main memory? How much better is page replacement algorithm x then LRU e.g. 2Q, ARC (currently best known techniques) How close can we come to LRU without doing any work between page faults? e.g. no scanning, constant work per page fault How important is recency vs. frequency in predicting page re-use?

No so good ideas What kind of music is made when I set the convert the address trace to notes? Can I make a fractal out of this data?

Today’s Topic: Optional Memory Management in Linux High level: 3 level page tables common kernel heap allocator (“kmalloc”, “slab”) Virtual memory areas Physical memory regions

Page Tables PGD = top level pointer PMD = middle level Points to a page of PMDs (page middle directory) PMD = middle level Can have just one entry for two-level hardware Points to a page of PTEs PTE = page table Translates a single virtual page into a physical page

Page Frame Database struct page { address_space * mapping; unsigned long index; // offset in mapping struct page * next_hash; struct page * prev_hash; unsigned long flags; atomic_t count; // usage count struct list_head lru; // pageout list void * virtual; // virtual address of this page in kernel memory map struct buffer_head * buffers; }

Page Flags PG_locked PC_error PG_referenced PG_uptodate PG_dirty PG_unused PG_lru PG_active PG_slab PG_highmem PG_checked …

Physical Memory Zones ZONE_DMA - used for DMA to antique devices, < 16 MB ZONE_NORMAL: 16-896 MB ZONE_HIGHMEM: > 896 MB

Linux Memory Picture Direct mapped: Virtually mapped: Zero 0-64k User 64k-3gb Physical Memory DMA Physical Memory Normal Kernel Virtual Memory Direct mapped: physical = virtual - 0xc0000000 Virtually mapped: physical = pte(virtual)

Page Replacement Triggered by low memory during allocation kswapd daemon also triggers swapping wakes up every second when few pages available try_to_free_pages() finds pages to release (many) walks through each memory type and asks it to release some pages

Page replacement (2) Two lists of memory active pages: currently actively in use inactive pages: candidates for swapping Pages are moved from active to inactive using clock algorithm active list scanned for non-referenced pages unused pages put on inactive list

Page replacement (3) Inactive list scanned for pages to swap out Put pages that have been referenced back on active list Leave behind pages locked for I/O Try to free buffers in buffer cache using the page Keep swapping out pages until enough have been freed

Issues How do you check reference bits on shared pages? What happens if the swapper needs to allocate memory? What happens if part of the swapper code is swapped out?

Slab Allocator Goal: Locality Fast Keep similar types together Can create a heap for a specific type Non-blocking synchronization Uses atomic instructions instead of locks

Slab Allocator Design struct page knows what cache holds memory Makes free easy - no need to specify/locate cache Heaps allocate from chunks called “slabs” 3 types: fully used - not used for allocation partially used - used first empty - reserved until no partially full Can span multiple page sizes optimized to reduce wastage

Page allocator Used for requesting contiguous chunks of physical memory Can specify zone (DMA, normal, highmem) Only allocates powers of 2 pages Used for I/O - need contigous physical memory or for single pages Uses buddy allocator coalesces adjacent pages into powers of 2 Triggers swapper when memory runs low Can wait until memory is available

Virtual Memory Areas Used when contiguous virtual address is needed e.g. allocating memory for dynamically loaded kernel code Kernel maintains sorted linked-list of areas in use traverses list to find free space allocate PMT/PTE/pages for the space

Page Fault Handler in arch/i386/mm/fault.c: do_page_fault() Looks up faulting address in virtual memory area list to see what kind of memory it is Checks common fault cases: usermode/kernel mode write protect / invalid stack growth lazy synchronization of page table Resolutions: call handle_mm_fault send SIGSEGV panic()