Re: [PATCH 2/4] block: inline fast path of driver tag allocation

Christoph Hellwig
2021-10-13T17:23:33Z

On Wed, Oct 13, 2021 at 10:49:35AM -0600, Jens Axboe wrote:
> If we don't use an IO scheduler or have shared tags, then we don't need
> to call into this external function at all. This saves ~2% for such
> a setup.

Hmm. What happens if you just throw an inline tag onto
blk_mq_get_driver_tag? All the high performance callers should be
in blk-mq.c anyway. If that isn't enough maybe something like the
version below?

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 38e6651d8b94c..ba9af26d5209d 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1126,18 +1126,23 @@ static bool __blk_mq_get_driver_tag(struct request *rq)
return true;
}

-bool blk_mq_get_driver_tag(struct request *rq)
+static void blk_mq_inc_active_requests(struct request *rq)
+{
+ if (!(rq->rq_flags & RQF_MQ_INFLIGHT)) {
+ rq->rq_flags |= RQF_MQ_INFLIGHT;
+ __blk_mq_inc_active_requests(rq->mq_hctx);
+ }
+}
+
+inline bool blk_mq_get_driver_tag(struct request *rq)
{
struct blk_mq_hw_ctx *hctx = rq->mq_hctx;

if (rq->tag == BLK_MQ_NO_TAG && !__blk_mq_get_driver_tag(rq))
return false;

- if ((hctx->flags & BLK_MQ_F_TAG_QUEUE_SHARED) &&
- !(rq->rq_flags & RQF_MQ_INFLIGHT)) {
- rq->rq_flags |= RQF_MQ_INFLIGHT;
- __blk_mq_inc_active_requests(hctx);
- }
+ if (hctx->flags & BLK_MQ_F_TAG_QUEUE_SHARED)
+ blk_mq_inc_active_requests(rq);
hctx->tags->rqs[rq->tag] = rq;
return true;
}