IOSched

From LQWiki
Jump to: navigation, search

IOSched or I/O Scheduler handles the scheduling of access to block devices such as the hard drive. There are four I/O schedulers algorithms in the 2.6 kernel, known as elevator algorithms. The elevator algorithms are Anticipatory (as), Deadline (deadline), CFQ (cfq) and No-Op (noop). The 2.4 kernel had only a single elevator known as Elevator_linus. It is often said that Elevator_linus is the same as the AS elevator, however this is not the case. Each of the 2.6 elevators is suited to its own task load so it can be worth experimenting.

It is possible to set the default elevator for all block devices at boot time and, in later 2.6 kernels, to set the elevator on a per block device level too. To set the default elevator first make sure the kernel has support for that scheduler. Next, as a boot parameter to the kernel, pass elevator="xxx" where xxx is one of as, deadline, cfq or noop. Per block device elevators are selected by editing the /sys/block/<device>/queue/scheduler file. Where an elevator allows you to tune some options these are set in /sys/block/<device>/queue/iosched/ and/or /sys/block/<device>/queue/.

When compiling your own kernels you can select the default scheduler to use, so a boot parameter is only needed to change schedulers from the compile time default. When reading about the elevators it may be worth understanding that the elevator simply reorders/delays/optimises the IO operations before passing them on to the FIFO queue for the block device you are writing to/reading from. The elevator isn't the queue for the actual device, and the device queue may be further optimised/rearranged by the devices hardware controller, but the kernel doesn't know anything about that.

Schedulers