From: John Garry <john.garry@huawei.com>
To: Bart Van Assche <bvanassche@acm.org>, Ming Lei <ming.lei@redhat.com>
Cc: "hare@suse.de" <hare@suse.de>,
"axboe@kernel.dk" <axboe@kernel.dk>, "hch@lst.de" <hch@lst.de>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"pragalla@codeaurora.org" <pragalla@codeaurora.org>,
"kashyap.desai@broadcom.com" <kashyap.desai@broadcom.com>,
yuyufen <yuyufen@huawei.com>
Subject: Re: [RFC PATCH v3 2/3] blk-mq: Freeze and quiesce all queues for tagset in elevator_exit()
Date: Tue, 16 Mar 2021 17:43:37 +0000 [thread overview]
Message-ID: <82526e78-66e5-fc3c-7acd-38f1813ebe1e@huawei.com> (raw)
In-Reply-To: <fff92b15-d483-ad6a-bb01-ef61117b7cbd@acm.org>
On 16/03/2021 17:00, Bart Van Assche wrote:
> On 3/16/21 9:15 AM, John Garry wrote:
>> I'll have a look at this ASAP - a bit busy.
>>
>> But a quick scan and I notice this:
>>
>> > @@ -226,6 +226,7 @@ static inline void
>> __blk_mq_put_driver_tag(struct blk_mq_hw_ctx *hctx,
>> > struct request *rq)
>> > {
>> > blk_mq_put_tag(hctx->tags, rq->mq_ctx, rq->tag);
>> > + rcu_assign_pointer(hctx->tags->rqs[rq->tag], NULL);
>>
>> Wasn't a requirement to not touch the fastpath at all, including even
>> if only NULLifying a pointer?
>>
>> IIRC, Kashyap some time ago had a patch like above (but without RCU
>> usage), but the request from Jens was to not touch the fastpath.
>>
>> Maybe I'm mistaken - I will try to dig up the thread.
>
Hi Bart,
>
> I agree that Jens asked at the end of 2018 not to touch the fast path to
> fix this use-after-free (maybe that request has been repeated more
> recently). If Jens or anyone else feels strongly about not clearing
> hctx->tags->rqs[rq->tag] from the fast path then I will make that
> change.
Is that possible for this same approach? I need to check the code more..
And don't we still have the problem that some iter callbacks may
sleep/block, which is not allowed in an RCU read-side critical section?
> My motivation for clearing these pointers from the fast path is
> as follows:
> - This results in code that is easier to read and easier to maintain.
> - Every modern CPU pipelines store instructions so the performance
> impact of adding an additional store should be small.
> - Since the block layer has a tendency to reuse tags that have been
> freed recently, it is likely that hctx->tags->rqs[rq->tag] will be used
> for a next request and hence that it will have to be loaded into the CPU
> cache anyway.
>
Those points make sense to me, but obviously it's the maintainers call.
Thanks,
john
next prev parent reply other threads:[~2021-03-16 17:46 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-05 15:14 [RFC PATCH v3 0/3] blk-mq: Avoid use-after-free for accessing old requests John Garry
2021-03-05 15:14 ` [RFC PATCH v3 1/3] blk-mq: Clean up references to old requests when freeing rqs John Garry
2021-03-06 2:52 ` Khazhy Kumykov
2021-03-08 11:18 ` John Garry
2021-03-06 18:13 ` Bart Van Assche
2021-03-08 10:37 ` John Garry
2021-03-05 15:14 ` [RFC PATCH v3 2/3] blk-mq: Freeze and quiesce all queues for tagset in elevator_exit() John Garry
2021-03-06 4:32 ` Bart Van Assche
2021-03-08 10:50 ` John Garry
2021-03-08 19:35 ` Bart Van Assche
2021-03-10 15:57 ` Bart Van Assche
2021-03-11 0:58 ` Ming Lei
2021-03-11 8:21 ` John Garry
2021-03-12 23:05 ` Bart Van Assche
2021-03-16 16:15 ` John Garry
2021-03-16 17:00 ` Bart Van Assche
2021-03-16 17:43 ` John Garry [this message]
2021-03-16 19:59 ` Bart Van Assche
2021-03-19 18:19 ` John Garry
2021-03-19 18:32 ` Bart Van Assche
2021-03-05 15:14 ` [RFC PATCH v3 3/3] blk-mq: Lockout tagset iterator when exiting elevator John Garry
2021-03-06 4:43 ` Bart Van Assche
2021-03-08 11:17 ` John Garry
2021-03-08 19:59 ` Bart Van Assche
2021-03-09 17:47 ` John Garry
2021-03-09 19:21 ` Bart Van Assche
2021-03-10 8:52 ` John Garry
2021-03-10 16:00 ` Bart Van Assche
2021-03-10 17:26 ` John Garry
2021-03-18 10:26 ` [RFC PATCH v3 0/3] blk-mq: Avoid use-after-free for accessing old requests Shinichiro Kawasaki
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=82526e78-66e5-fc3c-7acd-38f1813ebe1e@huawei.com \
--to=john.garry@huawei.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kashyap.desai@broadcom.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=pragalla@codeaurora.org \
--cc=yuyufen@huawei.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).