]> git.baikalelectronics.ru Git - kernel.git/commit
block: pre-allocate requests if plug is started and is a batch
authorJens Axboe <axboe@kernel.dk>
Wed, 6 Oct 2021 12:34:11 +0000 (06:34 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 18 Oct 2021 12:17:03 +0000 (06:17 -0600)
commit0a13ed03ca840e3cc116455cf42d0ca5260c7607
treea5c654c821d3b1bc49595a2e442d3ae3825e4919
parenta5bb764c62e19c47479f1c123efeb5a23ac70fe5
block: pre-allocate requests if plug is started and is a batch

The caller typically has a good (or even exact) idea of how many requests
it needs to submit. We can make the request/tag allocation a lot more
efficient if we just allocate N requests/tags upfront when we queue the
first bio from the batch.

Provide a new plug start helper that allows the caller to specify how many
IOs are expected. This sets plug->nr_ios, and we can use that for smarter
request allocation. The plug provides a holding spot for requests, and
request allocation will check it before calling into the normal request
allocation path.

The blk_finish_plug() is called, check if there are unused requests and
free them. This should not happen in normal operations. The exception is
if we get merging, then we may be left with requests that need freeing
when done.

This raises the per-core performance on my setup from ~5.8M to ~6.1M
IOPS.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-core.c
block/blk-mq.c
block/blk-mq.h
include/linux/blk-mq.h
include/linux/blkdev.h