From e42cfb1da0bf33c313318da201730324c423351d Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Fri, 18 Jun 2021 10:59:22 +0900 Subject: block: Remove unnecessary elevator operation checks The insert_requests and dispatch_request elevator operations are mandatory for the correct execution of an elevator, and all implemented elevators (bfq, kyber and mq-deadline) implement them. As a result, there is no need to check for these operations before calling them when a queue has an elevator set. This simplifies the code in __blk_mq_sched_dispatch_requests() and blk_mq_sched_insert_request(). To avoid out-of-tree elevators to crash the kernel in case of bad implementation, add a check in elv_register() to verify that these operations are implemented. A small, probably not significant, IOPS improvement of 0.1% is observed with this patch applied (4.117 MIOPS to 4.123 MIOPS, average of 20 fio runs doing 4K random direct reads with psync and 32 jobs). Signed-off-by: Damien Le Moal Reviewed-by: Johannes Thumshirn Link: https://lore.kernel.org/r/20210618015922.713999-1-damien.lemoal@wdc.com Signed-off-by: Jens Axboe --- block/elevator.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'block/elevator.c') diff --git a/block/elevator.c b/block/elevator.c index 06e203426410..85d0d4adbb64 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -522,6 +522,10 @@ void elv_unregister_queue(struct request_queue *q) int elv_register(struct elevator_type *e) { + /* insert_requests and dispatch_request are mandatory */ + if (WARN_ON_ONCE(!e->ops.insert_requests || !e->ops.dispatch_request)) + return -EINVAL; + /* create icq_cache if requested */ if (e->icq_size) { if (WARN_ON(e->icq_size < sizeof(struct io_cq)) || -- cgit v1.2.3