Linux Block I/O Scheduling. Aaron Carroll aaronc@gelato.unsw.edu.au December 22, 2007



Similar documents
Timing of a Disk I/O Transfer

CPU Scheduling. Basic Concepts. Basic Concepts (2) Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems

Chapter 11 I/O Management and Disk Scheduling

Scheduling 0 : Levels. High level scheduling: Medium level scheduling: Low level scheduling

CPU Scheduling. Core Definitions

CPU Scheduling Outline

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

Chapter 11 I/O Management and Disk Scheduling

I/O Management. General Computer Architecture. Goals for I/O. Levels of I/O. Naming. I/O Management. COMP755 Advanced Operating Systems 1

Comp 204: Computer Systems and Their Implementation. Lecture 12: Scheduling Algorithms cont d

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

Job Scheduling Model

Completely Fair Scheduler and its tuning 1

ICS Principles of Operating Systems

Linux Performance Optimizations for Big Data Environments

OPERATING SYSTEMS SCHEDULING

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

Operating Systems, 6 th ed. Test Bank Chapter 7

CPU Scheduling. CPU Scheduling

Introduction. Scheduling. Types of scheduling. The basics

Chapter 5 Process Scheduling

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

Objectives. Chapter 5: Process Scheduling. Chapter 5: Process Scheduling. 5.1 Basic Concepts. To introduce CPU scheduling

PERFORMANCE TUNING ORACLE RAC ON LINUX

Deep Dive: Maximizing EC2 & EBS Performance

FIOS: A Fair, Efficient Flash I/O Scheduler

Operating Systems. III. Scheduling.

Road Map. Scheduling. Types of Scheduling. Scheduling. CPU Scheduling. Job Scheduling. Dickinson College Computer Science 354 Spring 2010.

CPU Scheduling. Multitasking operating systems come in two flavours: cooperative multitasking and preemptive multitasking.

Linux scheduler history. We will be talking about the O(1) scheduler

Processor Scheduling. Queues Recall OS maintains various queues

Announcements. Basic Concepts. Histogram of Typical CPU- Burst Times. Dispatcher. CPU Scheduler. Burst Cycle. Reading

Lecture Outline Overview of real-time scheduling algorithms Outline relative strengths, weaknesses

Devices and Device Controllers

2. is the number of processes that are completed per time unit. A) CPU utilization B) Response time C) Turnaround time D) Throughput

Scheduling policy. ULK3e 7.1. Operating Systems: Scheduling in Linux p. 1

Quality of Service. Traditional Nonconverged Network. Traditional data traffic characteristics:

Objectives. Chapter 5: CPU Scheduling. CPU Scheduler. Non-preemptive and preemptive. Dispatcher. Alternating Sequence of CPU And I/O Bursts

Thomas Fahrig Senior Developer Hypervisor Team. Hypervisor Architecture Terminology Goals Basics Details

Performance and scalability of a large OLTP workload

Operatin g Systems: Internals and Design Principle s. Chapter 10 Multiprocessor and Real-Time Scheduling Seventh Edition By William Stallings

W4118 Operating Systems. Instructor: Junfeng Yang

Operating Systems Lecture #6: Process Management

OS OBJECTIVE QUESTIONS

Predictable response times in event-driven real-time systems

ò Paper reading assigned for next Thursday ò Lab 2 due next Friday ò What is cooperative multitasking? ò What is preemptive multitasking?

Lecture 3 Theoretical Foundations of RTOS

/ Operating Systems I. Process Scheduling. Warren R. Carithers Rob Duncan

HP Smart Array Controllers and basic RAID performance factors

Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum

Long-term monitoring of apparent latency in PREEMPT RT Linux real-time systems

A Comparative Study on Vega-HTTP & Popular Open-source Web-servers

Does Virtualization Make Disk Scheduling Passé?

Exercises : Real-time Scheduling analysis

ò Scheduling overview, key trade-offs, etc. ò O(1) scheduler older Linux scheduler ò Today: Completely Fair Scheduler (CFS) new hotness

Performance Comparison of RTOS

Tasks Schedule Analysis in RTAI/Linux-GPL

CHAPTER 1 INTRODUCTION

4. Fixed-Priority Scheduling

Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition

1 Storage Devices Summary

In-memory Tables Technology overview and solutions

W4118 Operating Systems. Instructor: Junfeng Yang

A Comparative Study of CPU Scheduling Algorithms

Faculty of Engineering Computer Engineering Department Islamic University of Gaza Network Chapter# 19 INTERNETWORK OPERATION

Performance Benchmark for Cloud Block Storage

Condusiv s V-locity Server Boosts Performance of SQL Server 2012 by 55%

Binary search tree with SIMD bandwidth optimization using SSE

Scheduling Algorithms

Aperiodic Task Scheduling

Understanding Linux on z/vm Steal Time

A Review on Load Balancing In Cloud Computing 1

How To Understand And Understand An Operating System In C Programming

Final Report. Cluster Scheduling. Submitted by: Priti Lohani

Real-Time Scheduling 1 / 39

Operating Systems CSE 410, Spring File Management. Stephen Wagner Michigan State University

Modular Real-Time Linux

These sub-systems are all highly dependent on each other. Any one of them with high utilization can easily cause problems in the other.

Scheduling. Scheduling. Scheduling levels. Decision to switch the running process can take place under the following circumstances:

Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 412, University of Maryland. Guest lecturer: David Hovemeyer.

Why Relative Share Does Not Work

File Management. Chapter 12

Operating System: Scheduling

KVM PERFORMANCE IMPROVEMENTS AND OPTIMIZATIONS. Mark Wagner Principal SW Engineer, Red Hat August 14, 2011

Power Management in the Linux Kernel

Kernel Optimizations for KVM. Rik van Riel Senior Software Engineer, Red Hat June

Introduction. Application Performance in the QLinux Multimedia Operating System. Solution: QLinux. Introduction. Outline. QLinux Design Principles

Linux Scheduler Analysis and Tuning for Parallel Processing on the Raspberry PI Platform. Ed Spetka Mike Kohler

University of Pennsylvania Department of Electrical and Systems Engineering Digital Audio Basics

System Software and TinyAUTOSAR

REAL TIME OPERATING SYSTEMS. Lesson-10:

EECS 750: Advanced Operating Systems. 01/28 /2015 Heechul Yun

Real- Time Scheduling

CPU Scheduling. CSC 256/456 - Operating Systems Fall TA: Mohammad Hedayati

Quiz 4 Solutions EECS 211: FUNDAMENTALS OF COMPUTER PROGRAMMING II. 1 Q u i z 4 S o l u t i o n s

Transcription:

Linux Block I/O Scheduling Aaron Carroll aaronc@gelato.unsw.edu.au December 22, 2007 As of version 2.6.24, the mainline Linux tree provides four block I/O schedulers: Noop, Deadline, Anticipatory (AS) and Completely Fair Queuing (CFQ). For benchmarking purposes, we have developed the First-In First-Out (FIFO) scheduler. 1 Background 1.1 Block Layer Structure The Linux block I/O subsystem is shown in Figure 1. As far as I/O scheduling is concerned, the key components are the elevator 1 layer, the I/O scheduler itself, and the dispatch queue. The elevator layer connects the scheduler with the generic block I/O layer via an interface exported by the scheduler. It also provides basic functionality common to many I/O schedulers, such as merge searching (see Section 1.3). The I/O scheduler is responsible for taking requests from the elevator layer, rearranging them according to some scheduling policy, and then populating the dispatch queue with requests which are consumed by the device driver and ultimately issued to the underlying device. 1.2 Merging Two I/O requests are said to be logically adjacent when the end-sector of one request corresponds to the sector immediately before the start of the other. If these requests are in the same direction (that is, read or write), they can then be merged into a single larger request. When searching for merge opportunities while adding a new request, two types of merges are possible: front- and back-merges. A front-merge occurs when the new request falls before an existing adjacent request, according to 1 Although the term elevator typically refers to a specific scheduling algorithm, Linux uses this term to refer generically to I/O schedulers. 1

I/O Scheduler Elevator Layer Block Layer Request Producer Dispatch Queue Device Driver Block Device Figure 1: Linux block layer structure start-sector order. When the new request falls after an existing request, a backmerge occurs. Figure 2 shows merging graphically; a request for sector 3 can be frontmerged with an exiting request for sectors 4 and 5, while the request for sector 6 can be back-merged with the same existing request. 1.2.1 Coalescing After an existing request has been involved in a merge, it is possible that the growth of the request causes it to become adjacent to another existing request. As with merging, these requests can then be coalesced into a single larger request. In Figure 2, after back-merging request 6 with the existing request for sectors 4 and 5, the resulting request (now for sectors 4, 5 and 6) can be coalesced with request 7. 1 4,5 3 Front merge Back merge 6 Coalesce 7 Figure 2: Request merging and coalescing 1.3 Elevator-layer Merging The Linux generic elevator layer maintains a hash table of requests indexed by end-sector number, which is used to discover back-merge opportunities with an ideally constant-time hash table lookup. No front-merging functionality is provided, and so must be implemented by each I/O scheduler if desired. 2

The elevator layer also provides a one-hit merge cache which stores the last request involved in a merge. This cache is checked for both front- and back-merge possibilities before performing a more general merge search. Requests involved in a merge are automatically coalesced using the elevator former req fn and elevator latter req fn functions which are provided by the I/O scheduler. 1.4 Synchronicity TODO: This section needs a better name Block requests can be classified into two types: synchronous and asynchronous. Synchronous requests are those which have a client process blocked waiting on the result of the request. These are usually the result of a read operation, such as through the read POSIX function. On the other hand, asynchronous requests do not have a client process blocked waiting on the result. Writes via calls to the write function usually result in asynchronous requests. TODO: This is strictly incorrect, but maybe close enough for practical purposes. The correlation between data direction (read and write) and synchronicity is not always the case. The aio * family of functions, for instance, allows issuing on asynchronous reads. open parameters, such as O DIRECT and O ASYNC, can also affect the synchronicity. 1.5 Tunables TODO: This section Describe what a tunable is and where to find them. 1.6 Scheduler API TODO: Do I want this? 3

2 Noop The Noop (no-operation) I/O scheduler provides minimal functionality, performing back-merging, limited coalescing, and sorting of requests only on the dispatch queue. Requests are organised in a simple first-in, first-out (FIFO) queue. Before adding a new request to the queue, back-merge opportunities are discovered and performed using the sector-indexed hash table provided by the generic elevator layer, but no front-merging is attempted. The scheduler will only coalesce requests that are adjacent both in sector position and in request order, since it does not know the sector-order of requests (no such data-structure is maintained). When dispatching a request, Noop will perform a sector-sorted insertion of the request on the front of its internal queue into the dispatch queue. Noop has no tunable parameters. 3 FIFO The FIFO, or First-In First-Out I/O scheduler issues requests to the disk in exactly the form they are received, without any merging or re-ordering. This simulates a system with no I/O scheduling capacity, and so can be used as a basis for benchmarking. FIFO has no tunables. 4

4 Deadline The goal of the Deadline I/O scheduler is to maximise global throughput while bounding time requests spend in the queue. 4.1 Architecture Requests in the Deadline scheduler are organised into two types of logical queues. The first, sort list, is a Red-Black (RB) tree sorted according to request sector number. It is used to traverse pending requests in increasing sector-order and for lookup of merge opportunities. Read and write requests are stored in separate sort lists. The second type of queue is the fifo list, which stores requests in FIFO order; that is, the oldest request is at the head of the queue. As with sort list, there are separate read and write queues which are implemented as doublylinked lists since only the front and back of the queue is of interest. New requests are added to both the fifo list and sort list corresponding to that request s data direction (read or write). 4.2 Batching Requests are normally added to the dispatch queue from the sort list queues in increasing-sector order, similar to the CSCAN algorithm, in batches. A batch consists of up to fifo batch contiguous (with respect to sector-number) requests of the same data direction which are treated as a single unit by the I/O scheduler. A batch is terminated when one of the following conditions occur: No more requests are available for the current batch s data direction; The next request is not sequential with respect to the last request dispatched; The current batch has dispatched fifo batch requests. 4.3 Deadlines Each request in the Deadline scheduler is assigned an expiry time (its deadline), which is determined by the read expire and write expire tunable (see Section 4.6), and dictates the maximum time this request should be allowed to go unserviced. Note these are soft deadlines and do not provide any sort of realtime performance guarantees; the actual service latency may be significantly greater (or indeed less) than the corresponding expiry time. When the request on the front of the fifo list expires (that is, its expiry time elapses), Deadline will expedite dispatch of that request. 5

4.4 Dispatch The following procedure is executed each time a new request is to be selected for dispatch: 1. Dispatch from the current batch until one of the conditions in Section 4.2 occur; 2. Select a new data direction. Choose reads unless there are no reads pending, or there are pending write requests that we have starved for too long, according to the writes starved tunable; 3. Check for an expired request in the fifo list queue of the selected data direction. If there is one, start a new batch with that request; 4. If we selected the same direction as the previous batch, start a new batch where the previous one left off; 5. Start a new batch at the request with the earliest expiry time in the chosen direction. New requests are always added to the tail of the dispatch queue. 4.5 Merging Deadline performs back-merging via the sector-sorted hash table provided by the elevator layer, along with optional front-merging (specified with the front merge tunable) which utilises sort list to discover adjacent requests. Requests that are made adjacent as a result of a merge are discovered and coalesced. 4.6 Tunables The Deadline scheduler exports five tunables to user-space. Table 1 summarises their function and default values. 6

Parameter Default Description read expire 500ms Expiry time for read requests. write expire 5s Expiry time for write requests. writes starved 2 Number of read batches to issue before switching to a write batch. front merge true Enables searching for front-merge opportunities. Back-merging is always performed. fifo batch 16 Maximum number of requests per batch. Table 1: Summary of Deadline tunable parameters 5 Anticipatory The Anticipatory scheduler (AS) aims to improve throughput by exploiting locality in I/O requests using a technique called anticipation. 5.1 Overview Structurally AS is similar to Deadline; requests are inserted into both sorted and FIFO queues. It also implements similar policies. AS always performs full backand front-merging and coalescing, and implements request deadlines which are tuned with read expire and write expire. AS also issues requests in batches, but unlike Deadline, the batches are time-based. Requests in AS batches do not need to be contiguous or even monotonic. The key difference between the Anticipatory and Deadline schedulers is the use of anticipation, discussed in Section 5.3. Strictly speaking, AS does not differentiate between read and write requests like Deadline, but rather synchronous and asynchronous requests. However, much of the existing documentation uses the terms read and write interchangeably with synchronous and asynchronous. 5.2 Batching A batch in the AS scheduler is a collection of requests in the same direction (not necessarily contiguous) over a fixed period of time: read batch expire ms for synchronous requests and write batch expire ms for asynchronous requests. Asynchronous batches are additionally limited to a number of requests which varies at run-time. This batch limit is adjusted according to measured time for previous batches to get actual batch times close to the specified time, write batch expire. New synchronous batches are started from the earliest entry in the FIFO queue. New asynchronous batches, however, continue from where the previous 7

asynchronous batch completed. TODO: This is now false. 5.3 Anticipation Anticipation aims to defeat a phenomenon called deceptive idleness [ID01]. When a process issues synchronous, sequential I/O requests, there is a period before the next request is issued, but after the previous one completes, where the process has no outstanding requests (the think-time). The scheduler may assume that the process has no further requests, and switch to servicing other processes. As a result, it may miss opportunities to issue sequential requests. If anticipation is likely to improve performance, AS will insert a pause of up to antic expire ms waiting for a suitable request. Anticipation will only occur during synchronous batches, and the following conditions must hold for a process if the scheduler will anticipate a request from it: 1. It has no outstanding requests; 2. It is still running, or it is likely cooperating with another process and either not running or likely to exit soon; 3. The mean think-time is less than antic expire; 4. There are no other synchronous requests available (from any process) that are closer than the one expected from this process. If the scheduler receives the request it was anticipating or a new synchronous request that is closer than the one anticipated, it will leave the anticipation state and immediately dispatch the request. If the request anticipated does not arrive within antic expire ms, the scheduler simply continues with the next request. 5.4 Dispatch AS alternates between dispatching read and write batches. Within each batch, requests are selected in a CSCAN-like manner. However, backward seeks are allowed if: 1. The nearest backward-request is more than twice as close as the nearest forward-request; and 2. The backward-request is no more than 512 MiB away from the current position. Before dispatching a request, and up to once per expiry period (read expire or write expire, depending on the current batch direction), the FIFO queue is checked for expired requests. If there is an expired request in the current data direction, it is immediately dispatched. 8

5.5 Tunables The tunables available for the Anticipatory scheduler are summarised in Table 2. Parameter Default Description read expire 125ms Expiry time for synchronous requests. write expire 250ms Expiry time for asynchronous requests. read batch expire 500ms How long to batch synchronous requests before switching to an asynchronous batch. write batch expire 125ms How long to batch asynchronous requests before switching to a synchronous batch. antic expire 6.7ms Maximum time to anticipate a synchronous request. Table 2: Summary of AS tunable parameters 9

6 CFQ The Completely Fair Queueing (CFQ) I/O scheduler tries to provide each competing process with an equal time share of access to the underlying device. It also provides many of the features of the Deadline and Anticipatory schedulers. 6.1 Priorities CFQ is currently the only scheduler that is aware of I/O priorities. Each process has an associated priority class, which defines what type of service is receives. The priority classes in order of priority are real-time (RT), best-effort (BE), and idle. The RT and BE classes are further divided into eight priority levels that indicate the level of service required within the class, with zero being the highest, and seven the lowest. If a process doesn t have its priority explicitly set, the class defaults to best-effort, and the level is derived from its nice value. 6.2 Structure The fundamental abstraction in CFQ is the cfq queue. Each queue acts as an independent source of requests, and the queues are serviced in a manner that allows priority-based fair queuing. Each process has its own cfq queue for synchronous requests. For asynchronous requests, there is one queue per priority eight RT queues, eight BE queues, and an idle queue. These are shared among all processes. As a consequence, per-process fairness only applies to synchronous requests. Priority is still respected. When a queue has requests pending, it is entered into the service tree, which stores the queues in the order in which they will be serviced. The order is a function of the queue s priority. Within each cfq queue, requests are stored in both a sector-sorted queue and a FIFO list. 6.3 Fairness CFQ 6.4 Dispatch Choosing the next request to dispatch is divided into two separate tasks: selecting the queue to service, and choosing a request within the queue. Before starting a dispatch, the following algorithm is used to select a queue: 1. If the current queue has requests pending and has not used its time slice, dispatch from that queue; 10

2. If the current queue has no requests pending but is idling or has requests in-flight, wait for completion before selecting a new queue; 3. Select the next queue in service order from the service tree. If it is an idle queue, only service it if slice idle ms have elapsed. Idle-class queues are limited to one request per round. All other queues are limited to quantum requests, and asynchronous queues have an additional request limit which is derived from its priority. 6.5 Tunables The tunables available for the Completely Fair Queueing scheduler are summarised in Table 3. Parameter Default Description back seek max 16384 KiB Maximum allowed size of backward seeks. back seek penalty 2 Factor by which forward seeks are considered better than backward seeks. fifo expire async 250ms Expiry time of asynchronous requests. fifo expire sync 125ms Expiry time of synchronous requests. quantum 4 Maximum requests per-queue to service each round. slice async 40ms Base time slice for asynchronous requests. slice async rq 2 Base number of asynchronous requests per round. slice idle 8ms Time to wait for a queue to produce more I/O before switching to a new queue. slice sync 100ms Base time slice for synchronous requests. Table 3: Summary of CFQ tunable parameters 11

References [ID01] S. Iyer and P. Druschel. Anticipatory scheduling: A disk scheduling framework to overcome deceptive idleness in synchronous I/O. In Proceedings of the 18th ACM Symposium on OS Principles, Banff, Canada, October 2001. 12