Linux I/O Schedulers

Changing the Scheduler

You can easily change the I/O scheduler in use. By default, that is CFQ, but if you want to change it to something like NOOP or deadline, you can, for example, change the default scheduler with the elevator= option, either manually at the kernel line during the boot process or in the GRUB configuration file.

To change the default I/O scheduler in GRUB, edit the /boot/grub/menu.lst file by adding the elevator= option. For example, you could change it from cfq to deadline by adding elevator=deadline to the end of the line that begins with kernel. Be sure to use lowercase for the name of the scheduler. After a change, run the update-grub command.

A second way to change the I/O scheduler is on the fly. For example, you can determine which I/O scheduler is being used by looking at the /sys/block/[device]/queue/scheduler file, where [device] is the name of the device. For example, on my laptop, the command

 

root@laytonjb-laptop:~# cat /sys/block/sdb/queue/scheduler
noop anticipatory deadline [cfq] 

 

shows that the current I/O scheduler (in square brackets) is cfq. To change the scheduler, just echo the name of the desired scheduler:

 

root@laytonjb-laptop:~# echo deadline > /sys/block/sdb/queue/scheduler
root@laytonjb-laptop:~# cat /sys/block/sdb/queue/scheduler
noop anticipatory [deadline] cfq 

 

Notice how the I/O scheduler was changed to deadline. When a change of scheduler is requested, the “old” scheduler completes all of its requests before control switches over to the new scheduler.

Summary

Today’s systems can have a large number of users, I/O-intensive workloads, requirements for high levels of interactivity, real-time demands, and a large number of disks and filesystems. Given the enormous strains that current systems impose on I/O subsystems, some way of controlling I/O requests is mandatory. This is where the I/O scheduler comes in.

The I/O scheduler is a very important tool for getting the best I/O performance. These schedulers can be designed to influence I/O and system behavior in whatever manner you desire. Currently, Linux includes four I/O schedulers: NOOP, anticipatory, deadline, and completely fair queuing (CFQ).

In this quick introduction to I/O schedulers, I did not discussed how to tune the various schedulers for your workload, which you can find in the documentation that comes with the source for your current kernel or online. Watching and measuring I/O performance can help you better understand your I/O workloads and how to get better performance.

The easiest way to change your I/O scheduler is to echo the name of the new scheduler to the appropriate device file in the /sys filesystem. The Phoronix website publishes test results for various workloads.