As documented in /usr/src/linux/Documentation/block/switching-sched.txt
, the I/O scheduler on any particular block device can be changed at runtime (there may be some latency as the previous scheduler's requests are all flushed before bringing the new scheduler into use, but it can be changed without problems even while the device is under heavy use).
# cat /sys/block/hda/queue/scheduler
noop anticipatory deadline [cfq]
# echo anticipatory > /sys/block/hda/queue/scheduler
# cat /sys/block/hda/queue/scheduler
noop [anticipatory] deadline cfq
Ideally, there would be a single scheduler to satisfy all needs. It doesn't seem to exist yet, so instead, Linux has several I/O schedulers. The kernel often doesn't have enough knowledge to choose the best scheduler for your workload:
noop
is often the best choice for memory-backed block devices (e.g. ramdisks) and other non-rotational media (flash) where trying to reschedule I/O is a waste of resources
as
(anticipatory
) is conceptually similar to deadline
, but with more heuristics that often improve performance (but sometimes can decrease it)
deadline
is a lightweight scheduler which tries to put a hard limit on latency
cfq
tries to maintain system-wide fairness of I/O bandwidth
The default was anticipatory
for a long time, and it received a lot of tuning. cfq
became the default some while ago, as its performance is reasonable and fairness is a good goal for multi-user systems (and even single-user desktops). For some scenarios -- databases are often used as examples, as they tend to already have their own peculiar scheduling and access patterns, and are often the most important service (so who cares about fairness?) -- anticipatory
has a long history of being tunable for best performance on these workloads, and deadline
very quickly passes all requests through to the underlying device.