public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Yu Kuai <yukuai3@huawei.com>
Cc: Yu Kuai <yukuai1@huaweicloud.com>, Yufen Yu <yuyufen@huawei.com>,
	axboe@kernel.dk, linux-block@vger.kernel.org, hch@lst.de,
	"zhangyi (F)" <yi.zhang@huawei.com>
Subject: Re: [PATCH] blk-mq: run queue after issuing the last request of the plug list
Date: Tue, 26 Jul 2022 09:46:56 +0800	[thread overview]
Message-ID: <Yt9HkP2mzH0ZTL1l@T590> (raw)
In-Reply-To: <ab899ae0-91fc-48db-cc32-fdc57f61963a@huawei.com>

On Tue, Jul 26, 2022 at 09:08:19AM +0800, Yu Kuai wrote:
> Hi, Ming!
> 
> 在 2022/07/25 23:43, Ming Lei 写道:
> > On Sat, Jul 23, 2022 at 10:50:03AM +0800, Yu Kuai wrote:
> > > Hi, Ming!
> > > 
> > > 在 2022/07/19 17:26, Ming Lei 写道:
> > > > On Mon, Jul 18, 2022 at 08:35:28PM +0800, Yufen Yu wrote:
> > > > > We do test on a virtio scsi device (/dev/sda) and the default mq
> > > > > scheduler is 'none'. We found a IO hung as following:
> > > > > 
> > > > > blk_finish_plug
> > > > >     blk_mq_plug_issue_direct
> > > > >         scsi_mq_get_budget
> > > > >         //get budget_token fail and sdev->restarts=1
> > > > > 
> > > > > 			     	 scsi_end_request
> > > > > 				   scsi_run_queue_async
> > > > >                                      //sdev->restart=0 and run queue
> > > > > 
> > > > >        blk_mq_request_bypass_insert
> > > > >           //add request to hctx->dispatch list
> > > > 
> > > > Here the issue shouldn't be related with scsi's get budget or
> > > > scsi_run_queue_async.
> > > > 
> > > > If blk-mq adds request into ->dispatch_list, it is blk-mq core's
> > > > responsibility to re-run queue for moving on. Can you investigate a
> > > > bit more why blk-mq doesn't run queue after adding request to
> > > > hctx dispatch list?
> > > 
> > > I think Yufen is probably thinking about the following Concurrent
> > > scenario:
> > > 
> > > blk_mq_flush_plug_list
> > > # assume there are three rq
> > >   blk_mq_plug_issue_direct
> > >    blk_mq_request_issue_directly
> > >    # dispatch rq1, succeed
> > >    blk_mq_request_issue_directly
> > >    # dispatch rq2
> > >     __blk_mq_try_issue_directly
> > >      blk_mq_get_dispatch_budget
> > >       scsi_mq_get_budget
> > >        atomic_inc(&sdev->restarts);
> > >        # rq2 failed to get budget
> > >        # restarts is 1 now
> > >                                          scsi_end_request
> > >                                          # rq1 is completed
> > >                                          ┊scsi_run_queue_async
> > >                                          ┊ atomic_cmpxchg(&sdev->restarts,
> > > old, 0) == old
> > >                                          ┊ # set restarts to 0
> > >                                          ┊ blk_mq_run_hw_queues
> > >                                          ┊ # hctx->dispatch list is empty
> > >    blk_mq_request_bypass_insert
> > >    # insert rq2 to hctx->dispatch list
> > 
> > After rq2 is added to ->dispatch_list in blk_mq_try_issue_list_directly(),
> > no matter if list_empty(list) is empty or not, queue will be run either from
> > blk_mq_request_bypass_insert() or blk_mq_sched_insert_requests().
> 
> 1) while inserting rq2 to dispatch list, blk_mq_request_bypass_insert()
> is called from blk_mq_try_issue_list_directly(), list_empty() won't
> pass, thus thus blk_mq_request_bypass_insert() won't run queue.

Yeah, but in blk_mq_try_issue_list_directly() after rq2 is inserted to dispatch
list, the loop is broken and blk_mq_try_issue_list_directly() returns to
blk_mq_sched_insert_requests() in which list_empty() is false, so
blk_mq_insert_requests() and blk_mq_run_hw_queue() are called, queue
is still run.

Also not sure why you make rq3 involved, since the list is local list on
stack, and it can be operated concurrently.

Thanks,
Ming


  reply	other threads:[~2022-07-26  1:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18 12:35 [PATCH] blk-mq: run queue after issuing the last request of the plug list Yufen Yu
2022-07-19  9:26 ` Ming Lei
2022-07-19 11:00   ` Yufen Yu
2022-07-23  2:50   ` Yu Kuai
2022-07-25 15:43     ` Ming Lei
2022-07-26  1:08       ` Yu Kuai
2022-07-26  1:46         ` Ming Lei [this message]
2022-07-26  2:08           ` Yu Kuai
2022-07-26  2:32             ` Ming Lei
2022-07-26  2:52               ` Yu Kuai
2022-07-26  3:02                 ` Ming Lei
2022-07-26  3:14                   ` Yu Kuai
2022-07-26  3:21                     ` Ming Lei
2022-07-26  3:31                       ` Yufen Yu
2022-07-26  3:31                       ` Yu Kuai
2022-07-26  4:16                         ` Ming Lei
2022-07-26  5:01                           ` Yufen Yu
2022-07-26  7:39                             ` Ming Lei
2022-07-26  9:20                               ` Yufen Yu

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=Yt9HkP2mzH0ZTL1l@T590 \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai1@huaweicloud.com \
    --cc=yukuai3@huawei.com \
    --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