From: John Garry <john.garry@huawei.com>
To: Bart Van Assche <bvanassche@acm.org>, Jens Axboe <axboe@kernel.dk>
Cc: <linux-block@vger.kernel.org>, Christoph Hellwig <hch@lst.de>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
Ming Lei <ming.lei@redhat.com>, "Hannes Reinecke" <hare@suse.de>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>,
Khazhy Kumykov <khazhy@google.com>
Subject: Re: [PATCH v6 2/5] blk-mq: Introduce atomic variants of blk_mq_(all_tag|tagset_busy)_iter
Date: Thu, 8 Apr 2021 13:48:16 +0100 [thread overview]
Message-ID: <14be9975-fbd1-796a-e44e-3342c5a330fb@huawei.com> (raw)
In-Reply-To: <1610af81-ce46-26c4-5aae-d84aba5cf1f5@acm.org>
On 07/04/2021 19:42, Bart Van Assche wrote:
>>
>>> - scsi_host_busy(), scsi_host_complete_all_commands() and
>>> scsi_host_busy_iter() are used by multiple SCSI LLDs so analyzing
>>> whether
>>> or not these functions may sleep is hard. Instead of performing that
>>> analysis, make it safe to call these functions from atomic context.
>>
>> Please help me understand this solution. The background is that we are
>> unsure if the SCSI iters callback functions may sleep. So we use the
>> blk_mq_all_tag_iter_atomic() iter, which tells us that we must not
>> sleep. And internally, it uses rcu read lock protection mechanism,
>> which relies on not sleeping. So it seems that we're making the SCSI
>> iter functions being safe in atomic context, and, as such, rely on the
>> iter callbacks not to sleep.
>>
>> But if we call the SCSI iter function from non-atomic context and the
>> iter callback may sleep, then that is a problem, right? We're still
>> using rcu.
>
Hi Bart,
>
> Please take a look at the output of the following grep command:
>
> git grep -nHEw 'blk_mq_tagset_busy_iter|scsi_host_busy_iter'\ drivers/scsi
>
> Do you agree with me that it is safe to call all the callback functions
> passed to blk_mq_tagset_busy_iter() and scsi_host_busy_iter() from an
> atomic context?
>
That list output I got is at the bottom (with this patchset, not
mainline - not sure which you meant).
The following does not look atomic safe with the mutex usage:
drivers/block/nbd.c:819: blk_mq_tagset_busy_iter(&nbd->tag_set,
nbd_clear_req, NULL);
static bool nbd_clear_req(struct request *req, void *data, bool reserved)
{
struct nbd_cmd *cmd = blk_mq_rq_to_pdu(req);
mutex_lock(&cmd->lock);
cmd->status = BLK_STS_IOERR;
mutex_unlock(&cmd->lock);
blk_mq_complete_request(req);
return true;
}
But blk_mq_tagset_busy_iter() uses BT_TAG_ITER_MAY sleep flag in your
series.
As for the fc, I am not sure. I assume that you would know more about
this. My concern is
__nvme_fc_abort_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_fcp_op *op)
{
...
ctrl->lport->ops->fcp_abort(&ctrl->lport->localport, ..);
}
Looking at many instances of fcp_abort callback, they look atomic safe
from general high usage of spinlock, but I am not certain. They are
quite complex.
Thanks,
John
block/blk-core.c:287: * blk_mq_tagset_busy_iter() and also for their
atomic variants to finish
block/blk-mq-debugfs.c:418:
blk_mq_tagset_busy_iter(hctx->queue->tag_set, hctx_show_busy_rq,
block/blk-mq-tag.c:405: * blk_mq_tagset_busy_iter - iterate over all
started requests in a tag set
block/blk-mq-tag.c:416:void blk_mq_tagset_busy_iter(struct
blk_mq_tag_set *tagset,
block/blk-mq-tag.c:436:EXPORT_SYMBOL(blk_mq_tagset_busy_iter);
drivers/block/mtip32xx/mtip32xx.c:2685:
blk_mq_tagset_busy_iter(&dd->tags, mtip_queue_cmd, dd);
drivers/block/mtip32xx/mtip32xx.c:2690:
blk_mq_tagset_busy_iter(&dd->tags,
drivers/block/mtip32xx/mtip32xx.c:3800:
blk_mq_tagset_busy_iter(&dd->tags, mtip_no_dev_cleanup, dd);
drivers/block/nbd.c:819: blk_mq_tagset_busy_iter(&nbd->tag_set,
nbd_clear_req, NULL);
drivers/nvme/host/core.c:392:
blk_mq_tagset_busy_iter(ctrl->tagset,
drivers/nvme/host/core.c:402:
blk_mq_tagset_busy_iter(ctrl->admin_tagset,
drivers/nvme/host/fc.c:2477:
blk_mq_tagset_busy_iter(&ctrl->tag_set,
drivers/nvme/host/fc.c:2500:
blk_mq_tagset_busy_iter(&ctrl->admin_tag_set,
drivers/nvme/host/pci.c:2504: blk_mq_tagset_busy_iter(&dev->tagset,
nvme_cancel_request, &dev->ctrl);
drivers/nvme/host/pci.c:2505:
blk_mq_tagset_busy_iter(&dev->admin_tagset, nvme_cancel_request,
&dev->ctrl);
drivers/nvme/target/loop.c:420:
blk_mq_tagset_busy_iter(&ctrl->tag_set,
drivers/nvme/target/loop.c:430:
blk_mq_tagset_busy_iter(&ctrl->admin_tag_set,
include/linux/blk-mq.h:527:void blk_mq_tagset_busy_iter(struct
blk_mq_tag_set *tagset,
lines 1-18/18 (END)
next prev parent reply other threads:[~2021-04-08 12:50 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-06 21:49 [PATCH v6 0/5] blk-mq: Fix a race between iterating over requests and freeing requests Bart Van Assche
2021-04-06 21:49 ` [PATCH v6 1/5] blk-mq: Move the elevator_exit() definition Bart Van Assche
2021-04-07 15:36 ` John Garry
2021-04-20 21:30 ` Bart Van Assche
2021-04-13 7:44 ` Daniel Wagner
2021-04-06 21:49 ` [PATCH v6 2/5] blk-mq: Introduce atomic variants of blk_mq_(all_tag|tagset_busy)_iter Bart Van Assche
2021-04-07 16:57 ` John Garry
2021-04-07 18:42 ` Bart Van Assche
2021-04-08 12:48 ` John Garry [this message]
2021-04-08 16:12 ` Bart Van Assche
2021-04-08 16:35 ` John Garry
2021-04-13 7:50 ` Daniel Wagner
2021-04-20 21:35 ` Bart Van Assche
2021-04-21 7:25 ` Daniel Wagner
2021-04-06 21:49 ` [PATCH v6 3/5] blk-mq: Fix races between iterating over requests and freeing requests Bart Van Assche
2021-04-07 0:02 ` Khazhy Kumykov
2021-04-07 21:54 ` Bart Van Assche
2021-04-20 21:41 ` Bart Van Assche
2021-04-06 21:49 ` [PATCH v6 4/5] blk-mq: Make it safe to use RCU to iterate over blk_mq_tag_set.tag_list Bart Van Assche
2021-04-06 21:49 ` [PATCH v6 5/5] blk-mq: Fix races between blk_mq_update_nr_hw_queues() and iterating over tags Bart Van Assche
2021-04-07 0:04 ` Khazhy Kumykov
2021-04-08 6:45 ` [PATCH v6 0/5] blk-mq: Fix a race between iterating over requests and freeing requests Shinichiro Kawasaki
2021-04-20 21:55 ` 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=14be9975-fbd1-796a-e44e-3342c5a330fb@huawei.com \
--to=john.garry@huawei.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=johannes.thumshirn@wdc.com \
--cc=khazhy@google.com \
--cc=linux-block@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ming.lei@redhat.com \
--cc=shinichiro.kawasaki@wdc.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).