From: Ming Lei <ming.lei@redhat.com>
To: Keith Busch <kbusch@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>, David Jeffery <djeffery@redhat.com>,
Bart Van Assche <bvanassche@acm.org>,
virtualization@lists.linux-foundation.org,
linux-block@vger.kernel.org,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [PATCH V2 1/1] blk-mq: avoid double ->queue_rq() because of early timeout
Date: Wed, 26 Oct 2022 11:29:48 +0800 [thread overview]
Message-ID: <Y1iprFhtHLSESDdJ@T590> (raw)
In-Reply-To: <Y1ilaQV3hz6kudH3@kbusch-mbp.dhcp.thefacebook.com>
On Tue, Oct 25, 2022 at 09:11:37PM -0600, Keith Busch wrote:
> On Wed, Oct 26, 2022 at 09:55:21AM +0800, Ming Lei wrote:
> > @@ -1564,8 +1571,13 @@ static bool blk_mq_check_expired(struct request *rq, void *priv)
> > * it was completed and reallocated as a new request after returning
> > * from blk_mq_check_expired().
> > */
> > - if (blk_mq_req_expired(rq, next))
> > + if (blk_mq_req_expired(rq, expired)) {
> > + if (expired->check_only) {
> > + expired->has_timedout_rq = true;
> > + return false;
> > + }
> > blk_mq_rq_timed_out(rq);
> > + }
> > return true;
> > }
> >
> > @@ -1573,7 +1585,10 @@ static void blk_mq_timeout_work(struct work_struct *work)
> > {
> > struct request_queue *q =
> > container_of(work, struct request_queue, timeout_work);
> > - unsigned long next = 0;
> > + struct blk_expired_data expired = {
> > + .check_only = true,
> > + .timeout_start = jiffies,
> > + };
> > struct blk_mq_hw_ctx *hctx;
> > unsigned long i;
> >
> > @@ -1593,10 +1608,24 @@ static void blk_mq_timeout_work(struct work_struct *work)
> > if (!percpu_ref_tryget(&q->q_usage_counter))
> > return;
> >
> > - blk_mq_queue_tag_busy_iter(q, blk_mq_check_expired, &next);
> > + /* check if there is any timed-out request */
> > + blk_mq_queue_tag_busy_iter(q, blk_mq_check_expired, &expired);
> > + if (expired.has_timedout_rq) {
> > + /*
> > + * Before walking tags, we must ensure any submit started
> > + * before the current time has finished. Since the submit
> > + * uses srcu or rcu, wait for a synchronization point to
> > + * ensure all running submits have finished
> > + */
> > + blk_mq_wait_quiesce_done(q);
> > +
> > + expired.check_only = false;
> > + expired.next = 0;
> > + blk_mq_queue_tag_busy_iter(q, blk_mq_check_expired, &expired);
>
> I think it would be easier to follow with separate callbacks instead of
> special casing for 'check_only'. One callback for checking timeouts, and
> a different one for handling them?
Both two are basically same, with two callbacks, just .check_only is saved,
nothing else, meantime with one extra similar callback added.
If you or anyone think it is one big deal, I can switch to two callback version.
Thanks,
Ming
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
prev parent reply other threads:[~2022-10-26 3:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-26 1:55 [PATCH V2 1/1] blk-mq: avoid double ->queue_rq() because of early timeout Ming Lei
[not found] ` <Y1ilaQV3hz6kudH3@kbusch-mbp.dhcp.thefacebook.com>
2022-10-26 3:29 ` Ming Lei [this message]
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=Y1iprFhtHLSESDdJ@T590 \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=djeffery@redhat.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux-foundation.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;
as well as URLs for NNTP newsgroup(s).