Penguin
Blame: LinuxIoScheduler
EditPageHistoryDiffInfoLikePages
Annotated edit history of LinuxIoScheduler version 17 showing authors affecting page license. View with all changes included.
Rev Author # Line
9 SujayParekh 1 The 2.6 LinuxKernel includes selectable [I/O] schedulers. They control the way the [Kernel] commits reads and writes to disks – the intention of providing different schedulers is to allow better optimisation for different classes of workload.
2
3 Without an I/O scheduler, the kernel would basically just issue each request to disk in the order that it received them. This could result in massive HardDisk thrashing: if one process was reading from one part of the disk, and one writing to another, the heads would have to seek back and forth across the disk for every operation. The scheduler’s main goal is to optimise disk access times.
4
5 An I/O scheduler can use the following techniques to improve performance:
6
7 ; Request merging: The scheduler merges adjacent requests together to reduce disk seeking
8 ; Elevator: The scheduler orders requests based on their physical location on the block device, and it basically tries to seek in one direction as much as possible.
9 ; Prioritisation: The scheduler has complete control over how it prioritises requests, and can do so in a number of ways
10
11 All I/O schedulers should also take into account resource starvation, to ensure requests eventually do get serviced!
12
13 !! The Schedulers
14
15 There are currently 4 available:
16
17 * No-op Scheduler
18 * Anticipatory IO Scheduler (AS)
19 * Deadline Scheduler
20 * Complete Fair Queueing Scheduler (CFQ)
21
22 ! No-op Scheduler
23
24 This scheduler only implements request merging.
25
26 ! Anticipatory IO Scheduler
27
11 DanielLawson 28 The anticipatory scheduler is the default scheduler in older 2.6 kernels – if you've not specified one, this is the one that will be loaded. It implements request merging, a one-way elevator, read and write request batching, and attempts some anticipatory reads by holding off a bit after a read batch if it thinks a user is going to ask for more data. It tries to optimise for physical disks by avoiding head movements if possible – one downside to this is that it probably give highly erratic performance on database or storage systems.
9 SujayParekh 29
30 ! Deadline Scheduler
31
32 The deadline scheduler implements request merging, a one-way elevator, and imposes a deadline on all operations to prevent resource starvation. Because writes return instantly within [Linux], with the actual data being held in cache, the deadline scheduler will also prefer readers – as long as the deadline for a write request hasn't passed. The kernel docs suggest this is the preferred scheduler for database systems, especially if you have [TCQ] aware disks, or any system with high disk performance.
33
34 ! Complete Fair Queueing Scheduler (CFQ)
35
11 DanielLawson 36 The complete fair queueing scheduler implements both request merging and the elevator, and attempts to give all users of a particular device the same number of IO requests over a particular time interval. This should make it more efficient for multiuser systems. It seems that Novel SLES sets cfq as the scheduler by default, as does the latest [Ubuntu] release. As of the 2.6.18 kernel, this is the default schedular in kernel.org releases.
9 SujayParekh 37
38 !! Changing Schedulers
39
40 The most reliable way to change schedulers is to set the kernel option “<tt>elevator</tt>” at boot time. You can set it to one of “<tt>as</tt>”, “<tt>cfq</tt>”, “<tt>deadline</tt>” or “<tt>noop</tt>”, to set the appropriate scheduler.
41
42 It seems under more recent 2.6 kernels (2.6.11, possibly earlier), you can change the scheduler at runtime by echoing the name of the scheduler into <tt>/sys/block/''$devicename''/queue/scheduler</tt>, where the device name is the basename of the block device, eg “<tt>sda</tt>” for <tt>/dev/sda</tt>.
43
44 !! Which one should I use?
45
46 I've not personally done any testing on this, so I can't speak from experience yet. The anticipatory scheduler will be the default one for a reason however - it is optimised for the common case. If you've only got single disk systems (ie, no RAID - hardware or software) then this scheduler is probably the right one for you. If it's a multiuser system, you will probably find CFQ or deadline providing better performance, and the numbers seem to back deadline giving the best performance for database systems.
17 RonnieCollinson 47
48 The noop scheduler has minimal cpu overhead in managing the queues and may be well suited to systems with either low seek times, such as an SSD or systems using a hardware RAID controller, which often has its own IO scheduler designed around the RAID semantics.
9 SujayParekh 49
50 !! Tuning the I/O schedulers
51
52 The schedulers may have parameters that can be tuned at runtime. Read the LinuxKernel documentation on the schedulers listed in the ''References'' section below
53
54 !! More information
55
56 Read the documents mentioned in the ''References'' section below, especially the LinuxKernel documentation on the anticipatory and deadline schedulers.
57
58 !! References
59 * [Tuning Linux 2.6 for the zSeries| http://awlinux1.alphaworks.ibm.com/developerworks/linux390/perf/tuning_rec_dasd_ioScheduler.shtml#begin ]
60 * [Linux I/O Schedulers|http://www.cs.ccu.edu.tw/~lhr89/linux-kernel/Linux%20IO%20Schedulers.pdf]
61 * [Benchmarking IO schedulers on the zSeries| http://awlinux1.alphaworks.ibm.com/developerworks/linux390/perf/tuning_res_dasd_IO_scheduler.shtml#begin]
62 * /usr/src/linux/Documentation/block/as-iosched.txt
63 * /usr/src/linux/Documentation/block/deadline-iosched.txt
64 * [Some Tunable Parameters for the CFQ Scheduler|http://lwn.net/Articles/101029/]
65 * [2003 Kerneltrap Thread Comparing IO Schedulers (Primarily AS vs. CFQ)|http://www.cs.rice.edu/~ssiyer/r/antsched/shines.html]
16 JohnMcPherson 66 * http://www.ibm.com/developerworks/linux/library/l-scheduler/
67 * [Process Scheduling|http://oreilly.com/catalog/linuxkernel/chapter/ch10.html]
9 SujayParekh 68
69 ----
70 Part of CategoryKernel