www.LinuxHowtos.org

Switching IO Schedulers on runtime

This manual explains how to change the IO-Scheduler used by your linux kernel without recompiling the kernel and without restart.
First, find out which schedulers are compiled and loaded into the kernel


bart:/sys/block/sda/queue # cat scheduler
anticipatory deadline [cfq]

cfq is selected here. I built noop as a module here, if I load it:

bart:/sys/block/sda/queue # modprobe noop-iosched

bart:/sys/block/sda/queue # cat scheduler
anticipatory deadline [cfq] noop

it shows up as well. Switching is just as simple, you simply echo the

desired scheduler into that file:
bart:/sys/block/sda/queue # echo anticipatory > scheduler
bart:/sys/block/sda/queue # cat scheduler
[anticipatory] deadline cfq noop


OK, to know which scheduler does what, here an explaination of those schedulers

This is just an executive summary. I don't know the details.
Normally a disk scheduler tries to balance between these goals:

A scheduler gets as input the list of sectors that processes have recently requested and which haven't yet given. It knows where the disk head currently is, and whatever other data it "remembers" from the past requests.

A typical scheduler is called cyclic elevator, where disk heads move from beginning of disk to the end of disk in one direction. Assume that you get some requests in a sorted queue, and you're going to satisfy them. So, you'll first filter the list of requests by deciding that you will not satisfy requests for sectors below your current head position. Then you'll simply go to the sector closest to your current position in your sorted list. So, crunch crunch crunch, you move from start of disk to the end of disk. When you reach the highest unsatisfied sector number, your cycle is over and you seek to the lowest unsatisfied sector. Rinse and repeat.

Linux 2.2 at least used the cyclic elevator if I remember right.

So, with these approximate goals in mind, we can look at the different schedulers available.

You want to use noop scheduler on devices where there are no seeking penalty, such as flash drives. That's why USB stick wants noop. Unfortunately, harddisks are very mechanial beasts and their performance is highly controlled by their seeking abilities. All these schedulers above are really trying to figure out how to extract maximum performance off the harddisk without causing bad behaviour in other cases.

most parts from http://kerneltrap.org/node/3851




rate this article:
current rating: average rating: 1.4 (204 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)

back