Re: [PATCH V8 4/7] blk-mq: introduce .get_budget and .put_budget in blk_mq_ops
From: Jens Axboe
Date: Fri Oct 13 2017 - 13:32:55 EST
On 10/13/2017 11:24 AM, Ming Lei wrote:
> For SCSI devices, there is often per-request-queue depth, which need
> to be respected before queuing one request.
>
> The current blk-mq always dequeues request first, then calls .queue_rq()
> to dispatch the request to lld. One obvious issue of this way is that I/O
> merge may not be good, because when the per-request-queue depth can't be
> respected, .queue_rq() has to return BLK_STS_RESOURCE, then this request
> has to stay in hctx->dispatch list, and never got chance to participate
> into I/O merge.
>
> This patch introduces .get_budget and .put_budget callback in blk_mq_ops,
> then we can try to get reserved budget first before dequeuing request.
> Once the budget for queueing I/O can't be satisfied, we don't need to
> dequeue request at all, then I/O merge can get improved a lot.
Still think this should be blk_mq_get_dispatch_budget(), like in the
incremental I sent out. That way you actually know what it is doing,
get_budget() could be anything.
> @@ -2582,6 +2606,9 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
> if (!set->ops->queue_rq)
> return -EINVAL;
>
> + if ((!!set->ops->get_budget) != (!!set->ops->put_budget))
> + return -EINVAL;
if (!set->ops->get_budget ^ !set->ops->put_budget)
is cleaner, imho.
--
Jens Axboe