Vnodes. Every open file has an associated vnode struct All file system types (FFS, NFS, etc.) have vnodes

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

CISC 7310X. C08: Virtual Memory. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/22/2018 CUNY Brooklyn College

Caching and Demand-Paged Virtual Memory

Page Replacement Algorithms

Chapter 10: Case Studies. So what happens in a real operating system?

ECE7995 Caching and Prefetching Techniques in Computer Systems. Lecture 8: Buffer Cache in Main Memory (I)

Reducing Miss Penalty: Read Priority over Write on Miss. Improving Cache Performance. Non-blocking Caches to reduce stalls on misses

CSE502: Computer Architecture CSE 502: Computer Architecture

Memory Management Virtual Memory

CS370 Operating Systems

Review: FFS background

VIRTUAL MEMORY READING: CHAPTER 9

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

Lecture 14: Cache & Virtual Memory

File Systems. Chapter 11, 13 OSPP

Virtual Memory. Today.! Virtual memory! Page replacement algorithms! Modeling page replacement algorithms

Memory management, part 2: outline

Week 2: Tiina Niklander

Review: FFS [McKusic] basics. Review: FFS background. Basic FFS data structures. FFS disk layout. FFS superblock. Cylinder groups

ADVANCED OPERATING SYSTEMS

Virtual Memory Design and Implementation

I/O Buffering and Streaming

File System Case Studies. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Operating Systems, Fall

Virtual memory. Virtual memory - Swapping. Large virtual memory. Processes

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

Ext3/4 file systems. Don Porter CSE 506

Memory Management. Chapter 4 Memory Management. Multiprogramming with Fixed Partitions. Ideally programmers want memory that is.

Da-Wei Chang CSIE.NCKU. Professor Hao-Ren Ke, National Chiao Tung University Professor Hsung-Pin Chang, National Chung Hsing University

Operating Systems Design Exam 2 Review: Spring 2011

ò Very reliable, best-of-breed traditional file system design ò Much like the JOS file system you are building now

CS 416: Opera-ng Systems Design March 23, 2012

Chapter 4: Memory Management. Part 1: Mechanisms for Managing Memory

Chapter 8 Virtual Memory

Topics. File Buffer Cache for Performance. What to Cache? COS 318: Operating Systems. File Performance and Reliability

Donn Morrison Department of Computer Science. TDT4255 Memory hierarchies

Chapter 9: Virtual Memory

File System Performance (and Abstractions) Kevin Webb Swarthmore College April 5, 2018

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?

SCSI overview. SCSI domain consists of devices and an SDS

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

Marten van Dijk Syed Kamran Haider, Chenglu Jin, Phuong Ha Nguyen. Department of Electrical & Computer Engineering University of Connecticut

Memory management, part 2: outline. Operating Systems, 2017, Danny Hendler and Amnon Meisels

Caching and reliability

Perform page replacement. (Fig 8.8 [Stal05])

Past: Making physical memory pretty

CSE502: Computer Architecture CSE 502: Computer Architecture

Virtual Memory Design and Implementation

Advanced Caching Techniques (2) Department of Electrical Engineering Stanford University

Why memory hierarchy? Memory hierarchy. Memory hierarchy goals. CS2410: Computer Architecture. L1 cache design. Sangyeun Cho

Chapter 8. Virtual Memory

Operating Systems CSE 410, Spring Virtual Memory. Stephen Wagner Michigan State University

Lecture 12: Demand Paging

Chapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition

CSE 153 Design of Operating Systems

Operating Systems. Operating Systems Sina Meraji U of T

ECE 571 Advanced Microprocessor-Based Design Lecture 13

Datenbanksysteme II: Caching and File Structures. Ulf Leser

Improving Cache Performance and Memory Management: From Absolute Addresses to Demand Paging. Highly-Associative Caches

416 Distributed Systems. Distributed File Systems 2 Jan 20, 2016

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

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

The Beast We Call A3. CS 161: Lecture 10 3/7/17

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

MEMORY: SWAPPING. Shivaram Venkataraman CS 537, Spring 2019

CS 333 Introduction to Operating Systems. Class 14 Page Replacement. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 14 Page Replacement. Jonathan Walpole Computer Science Portland State University

CS 4284 Systems Capstone

PROJECT 6: PINTOS FILE SYSTEM. CS124 Operating Systems Winter , Lecture 25

OPERATING SYSTEM. Chapter 9: Virtual Memory

Network File System (NFS)

Network File System (NFS)

Cache Lab Implementation and Blocking

VIRTUAL MEMORY II. Jo, Heeseung

Chapter 4 Memory Management. Memory Management

The Operating System. Chapter 6

Lecture 10: Large Cache Design III

File Systems Part 2. Operating Systems In Depth XV 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.

Paging algorithms. CS 241 February 10, Copyright : University of Illinois CS 241 Staff 1

CSE506: Operating Systems CSE 506: Operating Systems

Memory: Paging System

Midterm evaluations. Thank you for doing midterm evaluations! First time not everyone thought I was going too fast

RCU. ò Walk through two system calls in some detail. ò Open and read. ò Too much code to cover all FS system calls. ò 3 Cases for a dentry:

Address spaces and memory management

VFS, Continued. Don Porter CSE 506

CS 4284 Systems Capstone

read(2) There can be several cases where read returns less than the number of bytes requested:

What is an Operating System? A Whirlwind Tour of Operating Systems. How did OS evolve? How did OS evolve?

Operating Systems Design Exam 2 Review: Spring 2012

Computer Architecture Assignment 4 - Cache Simulator

Page 1. Goals for Today" TLB organization" CS162 Operating Systems and Systems Programming Lecture 11. Page Allocation and Replacement"

File System Internals. Jo, Heeseung

Last lecture. Some misc. stuff An older real processor Class review/overview.

Design Overview of the FreeBSD Kernel CIS 657

Operating Systems. Operating Systems Professor Sina Meraji U of T

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

CS162 Operating Systems and Systems Programming Lecture 11 Page Allocation and Replacement"

Outline. 1 Paging. 2 Eviction policies. 3 Thrashing 1 / 28

Chapter 11: Implementing File-Systems

ADRIAN PERRIG & TORSTEN HOEFLER Networks and Operating Systems ( ) Chapter 6: Demand Paging

Transcription:

Vnodes Every open file has an associated vnode struct All file system types (FFS, NFS, etc.) have vnodes - v data points to FS-specific data - Function pointers for operations (open/read/write/... ) When refcount 0,inactive() called - Does not deallocate vnode caches it - Files can very efficiently be reopened before deallocation - reclaim() revokes vnode for another use

Name cache Caches dir, name vnode translations - Both positive and negative lookups cached Need to invalidate all names for avnode (mv dir) - Each vnode has a capability, also contained in cache - Bump 32-bit capability to flush cache efficiently - When counter wraps, invalidate all of name cache Need to invalidate negative lookups when directory changed - Bump capability

Buffer cache Caches file blocks in memory - Hash table maps vnode, offset buffer - Freelists keep buffers not in use Operations on buffers: - bread() fill buffer from underlying file - breadn() likebread(), but start read ahead - brelse() relinquish unmodified buffer - bwrite() synchronously write data to disk - bawrite() asynchronously write data to disk - bdwrite() schedule delayed write

Write policies When to use synchronousbwrite()? - fsync() system call - Network file systems with synchronous writes - When cleaning reclaimed buffer - When order of disk writes matters When to usebdwrite()? - Buffer may be modified again When to usebawrite()? - Buffer full, might as well clean it

Buffer free lists Locked unused (for superblock?) LRU (or can replace with different algorithm) Age - Deleted files pushed onto front (reuse immediately) - Read-ahead blocks placed at end Empty - No physical memory

Algorithm: Optimal Definition: Maximize #hits/#references - Evict block that will be referenced furthest in the future How to implement - Gather trace of all references - Retroactively figure out what you should have done Useful only as a point of comparison LRU used to approximate algorithm - Most recently touched most likely to be touched soon If you could implement Optimal, is it best? - Best hit rate, but what about fairness?

Algorithm: FBR Idea: Weight blocks by frequency of reference - Count # of references - Evict blocks with lowest counts Problem: Many short-spaced references, then none - Don t bump count in new section of LRU queue Problem: Evicted right as blocks leave new - Only evict in old section of queue Problem: Never evict blocks with high count - Decay by half when total of counts reach some max

Algorithm: LRU-k LRU based on kth most recent access Regular LRU is LRU-1 LRU-2 works well in practice - Great for walking indexed data structures Computationally expensive - Costs log N to manipulate buffer (with cache size N)

Algorithm: 2Q Goal: Cheaper algorithm with benefits of LRU-2 Idea: Keep 2 queues: - A 1 for buffers accessed only once FIFO - A m for buffers accessed multiple times LRU Problem: Sizing A 1 vs. A m is hard Solution: Ghost buffers - Break A 1 into A 1in and A 1out - A 1out doesn t actually contain buffered data

Algorithm: SEQ Detect sequential accesses Apply MRU to pages fetched by sequential access Does not detect looping behavior

EELRU Idea: Ordinarily use simple LRU - If many recently fetched pages being evicted, move to fallback algorithm. Divide LRU queue into three regions - LRU region most recently accessed pages - early region less recently accessed pages - late region even less recently accessed pages - Use ghost buffers to track more buffers than memory size Evict from head of early or head of late point, based on mathematical predictions

Informed Prefetching & Caching [PGGSZ95] Idea: Improve I/O performance by giving OS hints What is a hint in computer systems? - Information that may improve performance - Does not have to be true (will not affect correctness) - Does not have to be heeded by system Two kinds of hints: Advice & Disclosure - Advice suggested policy, e.g., use MRU for this file - Disclosure gives notice of how App. will use OS interface, e.g., App. will read file 4 times Which is a better: Advice or disclosure?

Advantages of disclosure Remains correct when environment changes - Increases portability of application to different hardware Gives OS more info = More robust - OS may not be able to follow every process s advice e.g., not enough buffers to prefetch everything - Disclosure allows OS to optimize for actual resources Hints uses same abstractions as later operations - I.e., specified with fd/offsets, not inode/buffers - Better modularity

Disclosure interface Added disclosure ioctl call w. two arguments - File specifier: File descriptor or file name - Pattern specifier: Whole file, or list of offset,len pairs OS weighs needs/resources of hints vs. demand Buffer Consumers Buffer Suppliers demand miss service demand miss demand benefit Buffer Allocator LRU cost cached blocks LRU queue LRU cache prefetch prefetch benefit ejection cost hinted cache prefetched blocks cached blocks hinted sequence hinted sequence hinted sequence

Using speculative execution [CG99] Disclosure requires programmer to insert hints Idea: Automatically generate hints with spec. exec. - Application stalls waiting for a read - Spawn another thread, and continue executing w/o data - Issue prefetches for any further accesses Preventing side effects in speculative thread - Disallow all system calls except fstat (& sbrk) - Catch signals in case of errors like divide-by-zero - Implement software copy-on-write Make two copies of application text segment, instrument one for CoW Results: 20-70% improvement on many apps