Hi, >From within the block layer in the kernel, it is difficult to automatically detect the performance characteristics of the underlying storage. It was suggested by Jens Axboe at LSF2010 that we write a udev rule to tune the I/O scheduler properly for most cases. The basic approach is to leave CFQ's default tunings alone for SATA disks. For everything else, turn off slice idling and bump the quantum in order to drive higher queue depths. This patch is an attempt to implement this. I've tested it in a variety of configurations: - cciss devices - sata disks - sata ssds - enterprise storage (single path) - enterprise storage (multi-path) - multiple paths to a sata disk (yes, you can actually do that!) The tuning works as expected in all of those scenarios. I look forward to your comments. Thanks in advance! -Jeff Signed-off-by: Jeff Moyer <jmoyer@xxxxxxxxxx> diff --git a/Makefile.am b/Makefile.am index 032eb28..673c371 100644 --- a/Makefile.am +++ b/Makefile.am @@ -622,6 +622,16 @@ keymaps-distcheck-hook: extras/keymap/keys.txt $(top_srcdir)/extras/keymap/check-keymaps.sh $(top_srcdir) $^ DISTCHECK_HOOKS += keymaps-distcheck-hook +# ------------------------------------------------------------------------------ +# iosched - optimize I/O scheduler tunings +# ------------------------------------------------------------------------------ +EXTRA_DIST += extras/iosched/80-iosched.rules \ + extras/iosched/80-mpath-iosched.rules extras/iosched/mpath-iosched.sh +dist_udevrules_DATA += extras/iosched/80-iosched.rules \ + extras/iosched/80-mpath-iosched.rules +dist_libexec_SCRIPTS += extras/iosched/mpath-iosched.sh + + endif # ENABLE_EXTRAS # ------------------------------------------------------------------------------ diff --git a/extras/iosched/80-iosched.rules b/extras/iosched/80-iosched.rules new file mode 100644 index 0000000..163f240 --- /dev/null +++ b/extras/iosched/80-iosched.rules @@ -0,0 +1,14 @@ +# +# CFQ's default tunings are geared towards slow SATA disks. If we detect +# anything else, we change the tunings to drive deeper queue depths and +# keep the device busy. +# +SUBSYSTEM!="block", GOTO="end_iosched" +KERNEL=="dm-*", GOTO="end_iosched" +ENV{DEVTYPE}=="partition", GOTO="end_iosched" +ACTION!="add|change", GOTO="end_iosched" +ENV{ID_BUS}=="ata", GOTO="end_iosched" +ATTR{queue/scheduler}!="*\[cfq\]", GOTO="end_iosched" +ATTR{queue/iosched/slice_idle}="0" +ATTR{queue/iosched/quantum}="32" +LABEL="end_iosched" diff --git a/extras/iosched/80-mpath-iosched.rules b/extras/iosched/80-mpath-iosched.rules new file mode 100644 index 0000000..ece9e78 --- /dev/null +++ b/extras/iosched/80-mpath-iosched.rules @@ -0,0 +1,9 @@ +SUBSYSTEM!="block", GOTO="end_mpath_iosched" +ENV{DEVTYPE}=="partition", GOTO="end_mpath_iosched" +KERNEL!="dm-*", GOTO="end_mpath_iosched" +ACTION!="change", GOTO="end_mpath_iosched" +ATTR{queue/scheduler}!="*\[cfq\]", GOTO="end_mpath_iosched" +ENV{DM_UUID}!="mpath-?*", GOTO="end_mpath_iosched" +ENV{DM_ACTION}=="PATH_FAILED", GOTO="end_mpath_iosched" +RUN+="mpath-iosched.sh" +LABEL="end_mpath_iosched" diff --git a/extras/iosched/mpath-iosched.sh b/extras/iosched/mpath-iosched.sh new file mode 100755 index 0000000..51fb292 --- /dev/null +++ b/extras/iosched/mpath-iosched.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# +# For the request-based multipath driver, the I/O scheduler runs on the +# multipath device, not the underlying "slave" devices. This script +# checks the ID_BUS attribute for each of the slave devices. If it finds +# an ata device, it leaves the I/O scheduler tunings alone. For any other +# device, we tune the I/O scheduler to try to keep the device busy. +# +PATH=/sbin:$PATH + +needs_tuning=1 +for slave in /sys${DEVPATH}/slaves/*; do + bus_type=$(udevadm info --query=property --path=$slave | grep ID_BUS | awk -F= '{print $2}') + if [ "$bus_type" = "ata" ]; then + needs_tuning=0 + break + fi +done + +if [ $needs_tuning -eq 1 ]; then + echo 0 > /sys${DEVPATH}/queue/iosched/slice_idle + echo 32 > /sys${DEVPATH}/queue/iosched/quantum +fi + +exit 0 -- To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html