Jens Axboe provided a patch that makes the various IO schedulers fully modular, allowing people to switch between them on the fly. With the patch applied, on a running system you can switch between Nick Piggin [interview]'s anticipatory IO scheduler [story], Jens' deadline IO scheduler [story], Jens' CFQ IO scheduler [story], and the noop IO scheduler.
Jens points out that, "with the io schedulers fully modular, it is possible to add a new io scheduler type without touching the core kernel at all." He also notes that at least one scheduler must be compiled into the kernel, while the rest can be built as kernel modules. Read on for further details, including information on how to switch between schedulers.
From: Jens Axboe [email blocked] To: Linux Kernel [email blocked] Subject: [PATCH] modular io schedulers with online switching Date: Thu, 16 Sep 2004 16:59:38 +0200 Hi, This patch implements fully modular io schedulers and enables online switching between them. It adds a new sysfs entry in the block path that shows the current one in brackets and the other ones along side it: 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 Most of the patch is making q->elevator allocated instead of embedded inside the queue, and splitting elevator_t into two parts - one for the elvator_type (noop, deadline, etc) and elevator_queue that's an instance of that associated with a given queue. With the io schedulers fully modular, it is possible to add a new io scheduler type without touching the core kernel at all. elv_register() and elv_unregister() register a new io scheduler with the elevator core. Remember to build at least 1 io scheduler into the kernel, they can't all be modules :-) Patch is against current BK. [patch] -- Jens Axboe
From: Jens Axboe [email blocked] Subject: [PATCH] modular io schedulers with online switching, #2 Date: Fri, 17 Sep 2004 11:44:36 +0200 Hi, Changes since yesterday: - Don't allow AS to be unloaded, it has open io contexts attached to processes so we can't remove the functions that will be called on task exit. AS could be made unloadable by iterating each task in the system, calling exit_io_context() on tsk->io_context and clearing it. AS is still online switchable, you just cannot remove the module after it has been loaded. - Add module license to each scheduler - Move the chosen_elevator init and setup into elevator.c. Also sanity check given elevator= boot parameter and fall back to a default if it's invalid. This also gets rid of the ugly 'printed' crap in blk_init_queue() [patch] -- Jens Axboe