Skip to content

Instantly share code, notes, and snippets.

@l1x
Created November 10, 2012 04:06
Show Gist options
  • Save l1x/4049825 to your computer and use it in GitHub Desktop.
Save l1x/4049825 to your computer and use it in GitHub Desktop.
Configuring IO scheduler on Linux (boot time and run time) 2.6
4. Selecting a Scheduler
To specify a scheduler to be selected at boot time, add the following directive to the kernel line in /
boot/grub/grub.conf:
elevator=<elevator type>
For example, to specify that the noop scheduler should be selected at boot time, use:
elevator=noop
You can also select a scheduler during runtime. To do so, use this command:
echo <elevator type> > /sys/block/<device>/queue/scheduler
For example, to set the noop scheduler to be used on hda, use:
echo noop > /sys/block/hda/queue/scheduler
At any given time, you can view /sys/block/<device>/queue/scheduler (using cat, for
example) to verify which scheduler is being used by <device>. For example, if hda is using the noop
scheduler, then cat /sys/block/hda/queue/scheduler should return:
[noop] anticipatory deadline cfq
Note that selecting a scheduler in this manner is not persistent throughout system reboots. Unlike the
/proc/sys/ file system, the /sys/ file system does not have a utility similar to sysctl that can
make such changes persistent throughout system reboots.
To make your scheduler selection persistent throughout system reboots, edit /boot/grub/
grub.conf accordingly. Do this by appending elevator=<scheduler> to the the kernel line.
<scheduler> can be either noop, cfq, as (for anticipatory), or deadline.
For example, to ensure that the system selects the noop scheduler at boot-time:
title Red Hat Enterprise Linux Server (2.6.18-32.el5)
root (hd0,4)
kernel /boot/vmlinuz-2.6.18-32.el5 ro root=LABEL=/1 rhgb quiet
elevator=noop
initrd /boot/initrd-2.6.18-32.el5.img
5. Tuning a Scheduler and Device Request Queue
Parameters
Once you have selected a scheduler, you can also further tune its behavior through several request
queue parameters. Every I/O scheduler has its set of tunable options. These options are located (and
tuned) in /sys/block/<device>/queue/iosched/.
In addition to these, each device also has tunable request queue parameters located in /sys/
block/<device>/queue/.
Scheduler options and device request queue parameters are set in the same fashion. To set these
tuning options, echo the specified value to the specified tuning option, i.e.:
echo <value> > /sys/block/<device>/queue/iosched/<option>
For example: the system is currently using the anticipatory scheduler for device hda. To change /
sys/block/hda/queue/iosched/read_expire to 80 milliseconds, use:
echo 80 > /sys/block/hda/queue/iosched/read_expire
However, as mentioned in Section 4, “Selecting a Scheduler”, any tuning made though echo
commands to the /sys/ file system is not persistent thoughout system reboots. As such, to make any
scheduler selection/request queue settings persistent throughout system reboots, use /etc/rc.d/
rc.local.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment