Presentation is loading. Please wait.

Presentation is loading. Please wait.

Linux Block I/O Layer Chris Gill, Brian Kocoloski

Similar presentations


Presentation on theme: "Linux Block I/O Layer Chris Gill, Brian Kocoloski"— Presentation transcript:

1 Linux Block I/O Layer Chris Gill, Brian Kocoloski
CSE 422S - Operating Systems Organization Washington University in St. Louis St. Louis, MO 63130

2 Character vs. Block Devices
Character Devices Block Devices SD card keyboard hard disk drive serial port USB drive Data streams from a device sequentially Data can be randomly accessed in an arbitrary order by software CSE 422S – Operating Systems Organization

3 Character vs. Block Devices
Some input/output activities are stream-like E.g., keyboard events are accessed one-at-a-time, at a fixed “position” (the head of the stream) Such devices are called “character devices” Others can access different locations (in a file) E.g., data on a disk, in flash memory, etc. Stored in sectors, accessed in blocks (of multiple sectors) Such devices are called “block devices” Block size is power-of-two multiple of sector size May not be larger than physical memory page size Further distinguished by how blocks are accessed E.g., flash memory cards are truly random access E.g., disks involve “seeking” from one position to another CSE 422S – Operating Systems Organization

4 I/O scheduling for block devices
Performance comparison of most block devices with other hardware Reading/writing a CPU register: O(nanoseconds) Access memory in CPU cache: DRAM memory access: O(microseconds) Access to spinning hard drive: O(milliseconds) CSE 422S – Operating Systems Organization

5 Comparing orders of magnitude
Assume 1 nanosecond=1 minute 1 microsecond: almost 17 hours 1 millisecond: almost 2 years Takeaway: block I/O operations are much slower than most other hardware the kernel accesses CSE 422S – Operating Systems Organization

6 CSE 422S – Operating Systems Organization
Sectors and Blocks Hard disks typically have sectors, the size of which is specified by the device File system code operates on units called blocks Block size must be no smaller than sector size Block size must be no larger than physical memory page size Accessing disk sectors incurs several types of device-specific overhead Seek time Rotational latency LKD pp. 291 CSE 422S – Operating Systems Organization

7 CSE 422S – Operating Systems Organization
I/O Scheduling Way in in which I/O requests are handled matters At least, requests for adjacent blocks should be merged (fewer accesses gives lower overhead) Key ideas behind I/O scheduling: Request merging Request sorting Read-vs-write priority CSE 422S – Operating Systems Organization

8 CSE 422S – Operating Systems Organization
Linux Elevator Keeps sorted list of requests i.e.; assume requests are issued for blocks 2, 5, 0, and 8 Maintains sorted order 0,2,5,8 Total seek time? =8 Total seek time if using FIFO? =18 CSE 422S – Operating Systems Organization

9 Other I/O scheduling algs
deadline Prioritize read over writes Maintains three distinct request queues Sorted: all requests, sorted by disk sector Read FIFO: read requests, sorted by arrival time Write FIFO: write requests, sorted by arrival time LKD pp. 301 CSE 422S – Operating Systems Organization

10 Other I/O scheduling algs
anticipatory (as) Builds on deadline Tries to anticipate future read requests After scheduling a read operation, wait for a little bit to see if another read comes Assumes reads will come to nearby locations Why? LKD pp. 301 CSE 422S – Operating Systems Organization

11 Other I/O scheduling algs
Complete fair queuing (cfq) Fundamentally different from other algs Goal is per-process fairness All processes have their own scheduling queues, sorted by disk sector Noop No read-write priority or sorting based on disk sectors What is it used for? Block devices that can randomly access data just as easily as they can sequentially access data Solid state drives NVME flash drives CSE 422S – Operating Systems Organization

12 Recap: I/O “Elevators”
For disks, sequencing of reads (especially) is also important Like an “elevator” read position “seeks” along locations on disk Deadline scheduler (deadline) avoids starvation but keeps throughput Anticipatory scheduler (as) waits a little in case new request arrives Completely fair I/O scheduler (cfq) uses per-process fair queuing (it’s also Linux’ default I/O scheduler) CSE 422S – Operating Systems Organization


Download ppt "Linux Block I/O Layer Chris Gill, Brian Kocoloski"

Similar presentations


Ads by Google