blk-mq, elevator: Count requests per hctx to improve performance
authorKashyap Desai <kashyap.desai@broadcom.com>
Wed, 19 Aug 2020 15:20:28 +0000 (23:20 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 3 Sep 2020 21:20:47 +0000 (15:20 -0600)
commitb445547ec1bbd3e7bf4b1c142550942f70527d95
tree452adb8f18969cd32966206e046632f1d7ff9b44
parentf1b49fdc1c64db110aa1315831e5fe0f8599fa56
blk-mq, elevator: Count requests per hctx to improve performance

High CPU utilization on "native_queued_spin_lock_slowpath" due to lock
contention is possible for mq-deadline and bfq IO schedulers
when nr_hw_queues is more than one.

It is because kblockd work queue can submit IO from all online CPUs
(through blk_mq_run_hw_queues()) even though only one hctx has pending
commands.

The elevator callback .has_work for mq-deadline and bfq scheduler considers
pending work if there are any IOs on request queue but it does not account
hctx context.

Add a per-hctx 'elevator_queued' count to the hctx to avoid triggering
the elevator even though there are no requests queued.

[jpg: Relocated atomic_dec() in dd_dispatch_request(), update commit message per Kashyap]

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: John Garry <john.garry@huawei.com>
Tested-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bfq-iosched.c
block/blk-mq.c
block/mq-deadline.c
include/linux/blk-mq.h