From: Jens Axboe <axboe@kernel.dk>
To: Ming Lei <ming.lei@redhat.com>
Cc: linux-block@vger.kernel.org
Subject: Re: [PATCH 4/4] blk-mq: allocate tags in batches
Date: Mon, 30 Dec 2019 20:53:58 -0700 [thread overview]
Message-ID: <4587c4e6-a25f-9a68-ee6f-e0eb6da2e327@kernel.dk> (raw)
In-Reply-To: <20191231021834.GA20062@ming.t460p>
On 12/30/19 7:18 PM, Ming Lei wrote:
>> +static int blk_mq_get_tag_batch(struct blk_mq_alloc_data *data)
>> +{
>> + struct blk_mq_tags *tags = blk_mq_tags_from_data(data);
>> + struct sbitmap_queue *bt = &tags->bitmap_tags;
>> + struct blk_mq_ctx *ctx = data->ctx;
>> + int tag, cpu;
>> +
>> + if (!ctx)
>> + return -1;
>> +
>> + preempt_disable();
>> +
>> + /* bad luck if we got preempted coming in here, should be rare */
>> + cpu = smp_processor_id();
>> + if (unlikely(ctx->cpu != cpu)) {
>> + ctx = data->ctx = __blk_mq_get_ctx(data->q, cpu);
>> + data->hctx = blk_mq_map_queue(data->q, data->cmd_flags, ctx);
>
> When blk_mq_get_tag_batch is called for getting driver tag, rq->mq_hctx
> has been bound to the current request in blk_mq_rq_ctx_init(), so looks
> we shouldn't change hctx here.
->ctx is also NULL for that case, so it gets skipped. Probably needs a
comment...
I'll need to check if all cases are covered, the batched tags should be
exclusive to the non-reserved, regular tags. Or just the scheduler tags,
if a scheduler is attached. Not sure it makes a lot of sense to handle
the scheduler case as well (and have two sets of batches, driver tags
and scheduler tags), but if it does, we could extend it for that and
just bail if we're not on the right ctx anymore. In all honesty, I wrote
that above code without ever checking that it happens. It most certainly
could, but I'd consider it a very low risk. So might be better to simply
just return -1 for that case and ignore it.
--
Jens Axboe
next prev parent reply other threads:[~2019-12-31 3:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-30 18:14 [PATCHSET 0/4] blk-mq: per-ctx tag caching Jens Axboe
2019-12-30 18:14 ` [PATCH 1/4] sbitmap: remove cleared bitmask Jens Axboe
2019-12-30 18:14 ` [PATCH 2/4] sbitmap: mask out top bits that can't be used Jens Axboe
2019-12-30 18:14 ` [PATCH 3/4] sbitmap: add batch tag retrieval Jens Axboe
2019-12-30 18:14 ` [PATCH 4/4] blk-mq: allocate tags in batches Jens Axboe
2019-12-31 2:18 ` Ming Lei
2019-12-31 3:53 ` Jens Axboe [this message]
2019-12-31 4:11 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4587c4e6-a25f-9a68-ee6f-e0eb6da2e327@kernel.dk \
--to=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).