From: Bart Van Assche <bvanassche@acm.org>
To: John Garry <john.garry@huawei.com>, axboe@kernel.dk, ming.lei@redhat.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
hch@lst.de, hare@suse.de, ppvk@codeaurora.org,
kashyap.desai@broadcom.com, linuxarm@huawei.com
Subject: Re: [RFC PATCH v2 2/2] blk-mq: Lockout tagset iter when freeing rqs
Date: Thu, 17 Dec 2020 17:55:51 -0800 [thread overview]
Message-ID: <30c16455-6d7d-39ac-b3fc-4ee38199e683@acm.org> (raw)
In-Reply-To: <1608203273-170555-3-git-send-email-john.garry@huawei.com>
On 12/17/20 3:07 AM, John Garry wrote:
> diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
> index a6df2d5df88a..853ed5b889aa 100644
> --- a/block/blk-mq-tag.c
> +++ b/block/blk-mq-tag.c
> @@ -358,10 +358,19 @@ void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
> {
> int i;
>
> for (i = 0; i < tagset->nr_hw_queues; i++) {
> - if (tagset->tags && tagset->tags[i])
> - __blk_mq_all_tag_iter(tagset->tags[i], fn, priv,
> + if (tagset->tags && tagset->tags[i]) {
> + struct blk_mq_tags *tags = tagset->tags[i];
> +
> + if (!atomic_inc_not_zero(&tags->iter_usage_counter))
> + continue;
> +
> + __blk_mq_all_tag_iter(tags, fn, priv,
> BT_TAG_ITER_STARTED);
> +
> + atomic_dec(&tags->iter_usage_counter);
> + }
> }
> }
Atomic operations are (a) more expensive than rcu_read_lock() /
rcu_read_lock() and (b) do not provide the same guarantees.
rcu_read_lock() has acquire semantics and rcu_read_unlock() has
release semantics. Regular atomic operations do not have these
semantics which means that the CPU is allowed to reorder certain
regular loads and stores against atomic operations. Additionally,
atomic operations are more expensive than the corresponding RCU
primitives. In other words, I would be much happier if this patch
series would use RCU instead of atomics.
Thanks,
Bart.
next prev parent reply other threads:[~2020-12-18 1:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-17 11:07 [RFC PATCH v2 0/2] blk-mq: Avoid use-after-free for accessing old requests John Garry
2020-12-17 11:07 ` [RFC PATCH v2 1/2] blk-mq: Clean up references to old requests when freeing rqs John Garry
2020-12-17 11:07 ` [RFC PATCH v2 2/2] blk-mq: Lockout tagset iter " John Garry
2020-12-18 1:55 ` Bart Van Assche [this message]
2020-12-18 9:30 ` John Garry
2020-12-18 3:31 ` Ming Lei
2020-12-18 10:01 ` John Garry
2020-12-18 22:43 ` Bart Van Assche
2020-12-21 12:06 ` John Garry
2020-12-21 18:09 ` Bart Van Assche
2020-12-21 18:47 ` John Garry
2020-12-22 2:13 ` Bart Van Assche
2020-12-22 11:15 ` John Garry
2020-12-22 16:16 ` Bart Van Assche
2020-12-23 11:10 ` John Garry
2020-12-23 11:40 ` John Garry
2020-12-23 15:47 ` Bart Van Assche
2021-01-04 15:33 ` John Garry
2021-01-04 17:22 ` Bart Van Assche
2021-01-04 18:43 ` John Garry
[not found] ` <760304b3-dcbc-5b9d-0c70-627b7ff5b4eb@huawei.com>
2021-02-10 14:39 ` John Garry
2020-12-22 11:22 ` John Garry
2020-12-22 13:24 ` Ming Lei
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=30c16455-6d7d-39ac-b3fc-4ee38199e683@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=john.garry@huawei.com \
--cc=kashyap.desai@broadcom.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=ming.lei@redhat.com \
--cc=ppvk@codeaurora.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
all inboxes | Powered by JetHome®