From: Nilay Shroff <nilay@linux.ibm.com>
To: Daniel Wagner <wagi@kernel.org>, Keith Busch <kbusch@kernel.org>,
Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
Sagi Grimberg <sagi@grimberg.me>, Ming Lei <ming.lei@redhat.com>
Cc: James Smart <james.smart@broadcom.com>,
Hannes Reinecke <hare@suse.de>,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-block@vger.kernel.org
Subject: Re: [PATCH 3/3] blk-mq: fix wait condition for tagset wait completed check
Date: Wed, 29 Jan 2025 15:24:52 +0530 [thread overview]
Message-ID: <669a9e1c-bde2-4323-b997-cdbd82a26eab@linux.ibm.com> (raw)
In-Reply-To: <20250128-nvme-misc-fixes-v1-3-40c586581171@kernel.org>
On 1/28/25 10:04 PM, Daniel Wagner wrote:
> blk_mq_tagset_count_completed_reqs returns the number of completed
> requests. The only user of this function is
> blk_mq_tagset_wait_completed_request which wants to know how many
> request are not yet completed. Thus return the number of in flight
> requests and terminate the wait loop when there is no inflight request.
>
> Fixes: f9934a80f91d ("blk-mq: introduce blk_mq_tagset_wait_completed_request()")
> Cc: Ming Lei <ming.lei@redhat.com>
> Signed-off-by: Daniel Wagner <wagi@kernel.org>
> ---
> block/blk-mq-tag.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
> index b9f417d980b46d54b74dec8adcb5b04e6a78635c..3ce46afb65e3c3de9f11ca440bf0f335f21d0998 100644
> --- a/block/blk-mq-tag.c
> +++ b/block/blk-mq-tag.c
> @@ -450,11 +450,11 @@ void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
> }
> EXPORT_SYMBOL(blk_mq_tagset_busy_iter);
>
> -static bool blk_mq_tagset_count_completed_rqs(struct request *rq, void *data)
> +static bool blk_mq_tagset_count_inflight_rqs(struct request *rq, void *data)
> {
> unsigned *count = data;
>
> - if (blk_mq_request_completed(rq))
> + if (blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT)
> (*count)++;
> return true;
> }
> @@ -472,7 +472,7 @@ void blk_mq_tagset_wait_completed_request(struct blk_mq_tag_set *tagset)
> unsigned count = 0;
>
> blk_mq_tagset_busy_iter(tagset,
> - blk_mq_tagset_count_completed_rqs, &count);
> + blk_mq_tagset_count_inflight_rqs, &count);
> if (!count)
> break;
> msleep(5);
>
I see that blk_mq_tagset_wait_completed_request() is called from nvme_cancel_tagset()
and nvme_cancel_admin_tagset(). And it seems to me that the intention here's to wait
until each completed requests are freed (or change its state to MQ_RQ_IDLE).
Looking at code, the nvme_cancel_xxx() first invokes blk_mq_tagset_busy_iter() which
iterates through tagset and cancels each in-flight request and marks the request state
to MQ_RQ_COMPLETE. Next in blk_mq_tagset_wait_completed_request(), we wait for each
completed request state changed to anything but MQ_RQ_COMPLETE. The next state of the
request would be naturally MQ_RQ_IDLE once that request is freed. So in blk_mq_tagset_
wait_completed_request(), essentially we wait for request state change from MQ_RQ_COMPLETE
to MQ_RQ_IDLE.
So now if the proposal is that blk_mq_tagset_wait_completed_request() has to wait only
if there's any in-flight request then it seems this function would never need to wait
and looks redundant because req->state would never be MQ_RQ_IN_FLIGHT as those would
have been already changed to MQ_RQ_COMPLETE when nvme_cancel_xxx() invokes blk_mq_tagset_
busy_iter(ctrl->tagset, nvme_cancel_request, ctrl).
Having said that, I am not sure what was the real intention here, in nvme_cancel_xxx(),
do we really need to wait only until in-flight requests are completed or synchronize with
request's completion callback (i.e. wait until all completed requests are freed)?
Thanks,
--Nilay
next prev parent reply other threads:[~2025-01-29 9:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-28 16:34 [PATCH 0/3] misc nvme related fixes Daniel Wagner
2025-01-28 16:34 ` [PATCH 1/3] nvme-tcp: rate limit error message in send path Daniel Wagner
2025-01-29 6:05 ` Christoph Hellwig
2025-01-30 15:25 ` Daniel Wagner
2025-01-31 7:29 ` Christoph Hellwig
2025-01-31 8:09 ` Sagi Grimberg
2025-01-31 8:09 ` Sagi Grimberg
2025-01-28 16:34 ` [PATCH 2/3] nvme-fc: use ctrl state getter Daniel Wagner
2025-01-29 6:05 ` Christoph Hellwig
2025-01-29 18:39 ` Keith Busch
2025-01-31 8:09 ` Sagi Grimberg
2025-01-28 16:34 ` [PATCH 3/3] blk-mq: fix wait condition for tagset wait completed check Daniel Wagner
2025-01-29 6:07 ` Christoph Hellwig
2025-01-29 9:54 ` Nilay Shroff [this message]
2025-01-31 8:13 ` Sagi Grimberg
2025-01-31 8:46 ` Daniel Wagner
2025-01-31 8:54 ` Christoph Hellwig
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=669a9e1c-bde2-4323-b997-cdbd82a26eab@linux.ibm.com \
--to=nilay@linux.ibm.com \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=james.smart@broadcom.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=ming.lei@redhat.com \
--cc=sagi@grimberg.me \
--cc=wagi@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