From: Jens Axboe <axboe@kernel.dk>
To: Bart Van Assche <Bart.VanAssche@wdc.com>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Cc: "brking@linux.vnet.ibm.com" <brking@linux.vnet.ibm.com>
Subject: Re: [PATCH 1/4] blk-mq-tag: check for NULL rq when iterating tags
Date: Thu, 3 Aug 2017 14:56:45 -0600 [thread overview]
Message-ID: <5bb23d5d-2d09-333f-5570-a0f9925cd44c@kernel.dk> (raw)
In-Reply-To: <1501793402.2922.20.camel@wdc.com>
On 08/03/2017 02:50 PM, Bart Van Assche wrote:
> On Thu, 2017-08-03 at 14:40 -0600, Jens Axboe wrote:
>> On 08/03/2017 02:35 PM, Jens Axboe wrote:
>>>> I agree with what you wrote in the description of this patch.
>>>> However, since I have not yet found the code that clears tags->rqs[],
>>>> would it be possible to show me that code?
>>>
>>> Since it's been a month since I wrote this code, I went and looked
>>> too. My memory was that we set/clear it dynamically since we added
>>> scheduling, but looks like we don't clear it. The race is still valid
>>> for when someone runs a tag check in parallel with someone allocating
>>> a tag, since there's a window of time where the tag bit is set, but
>>> ->rqs[tag] isn't set yet. That's probably the race I hit, not the
>>> completion race mentioned in the change log.
>>
>> Rewrote the commit message:
>>
>> http://git.kernel.dk/cgit/linux-block/commit/?h=mq-inflight&id=1908e43118e688e41ac8656edcf3e7a150f3f5081
>
> Hello Jens,
>
> This is what I found in the updated commit:
>
> blk-mq-tag: check for NULL rq when iterating tags
>
> Since we introduced blk-mq-sched, the tags->rqs[] array has been
> dynamically assigned. So we need to check for NULL when iterating,
> since there's a window of time where the bit is set, but we haven't
> dynamically assigned the tags->rqs[] array position yet.
>
> This is perfectly safe, since the memory backing of the request is
> never going away while the device is alive.
>
> Does this mean that blk_mq_tagset_busy_iter() can skip requests that it
> shouldn't skip and also that blk_mq_tagset_busy_iter() can pass a pointer to
> the previous request that was associated with a tag instead of the current
> request to its busy_tag_iter_fn argument? Shouldn't these races be fixed,
> e.g. by swapping the order in which the tag are set and tags->rqs[] are
> assigned such that the correct request pointer is passed to the
> busy_tag_iter_fn argument?
We can't swap them. We need to reserve a bit first, which entails
setting that bit. Once that's set, we can assign ->rqs[]. The race isn't
a big deal, and I don't want to add any code to prevent it, since that
would mean locking. Since we have the luxury of the request itself
always being valid memory, we can deal with stale info or having a NULL
because of the ordering. It's a conscious trade off.
--
Jens Axboe
next prev parent reply other threads:[~2017-08-03 20:56 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-03 20:01 [PATCH 0/4] block: more scalable inflight tracking Jens Axboe
2017-08-03 20:01 ` [PATCH 1/4] blk-mq-tag: check for NULL rq when iterating tags Jens Axboe
2017-08-03 20:29 ` Bart Van Assche
2017-08-03 20:35 ` Jens Axboe
2017-08-03 20:40 ` Jens Axboe
2017-08-03 20:50 ` Bart Van Assche
2017-08-03 20:56 ` Jens Axboe [this message]
2017-08-03 20:01 ` [PATCH 2/4] block: pass in queue to inflight accounting Jens Axboe
2017-08-03 20:35 ` Bart Van Assche
2017-08-03 20:37 ` Jens Axboe
2017-08-03 20:01 ` [PATCH 3/4] blk-mq: provide internal in-flight variant Jens Axboe
2017-08-03 20:41 ` Bart Van Assche
2017-08-03 20:45 ` Jens Axboe
2017-08-03 20:54 ` Bart Van Assche
2017-08-03 21:25 ` Bart Van Assche
2017-08-03 22:36 ` Jens Axboe
2017-08-04 11:17 ` Ming Lei
2017-08-04 13:55 ` Jens Axboe
2017-08-04 22:19 ` Ming Lei
2017-08-07 19:54 ` Brian King
2017-08-03 20:01 ` [PATCH 4/4] blk-mq: enable checking two part inflight counts at the same time Jens Axboe
2017-08-03 21:29 ` Bart Van Assche
2017-08-03 22:38 ` Jens Axboe
2017-08-03 22:30 ` Bart Van Assche
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=5bb23d5d-2d09-333f-5570-a0f9925cd44c@kernel.dk \
--to=axboe@kernel.dk \
--cc=Bart.VanAssche@wdc.com \
--cc=brking@linux.vnet.ibm.com \
--cc=linux-block@vger.kernel.org \
/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