All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Hannes Reinecke <hare@suse.de>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, Salman Qazi <sqazi@google.com>,
	Jesse Barnes <jsbarnes@google.com>,
	Christoph Hellwig <hch@lst.de>,
	Bart Van Assche <bvanassche@acm.org>
Subject: Re: [PATCH 1/2] block: add blk_default_io_timeout() for avoiding task hung in sync IO
Date: Tue, 28 Apr 2020 16:30:47 +0800	[thread overview]
Message-ID: <20200428083047.GA624552@T590> (raw)
In-Reply-To: <71710192-1262-6f08-e38b-565ec6a32858@suse.de>

On Tue, Apr 28, 2020 at 10:05:36AM +0200, Hannes Reinecke wrote:
> On 4/28/20 9:46 AM, Ming Lei wrote:
> > Add helper of blk_default_io_timeout(), so that the two current users
> > can benefit from it.
> > 
> > Also direct IO users will use it in the following patch, so define the
> > helper in public header.
> > 
> > Cc: Salman Qazi <sqazi@google.com>
> > Cc: Jesse Barnes <jsbarnes@google.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Cc: Bart Van Assche <bvanassche@acm.org>
> > Signed-off-by: Ming Lei <ming.lei@redhat.com>
> > ---
> >   block/bio.c            |  9 +++------
> >   block/blk-exec.c       |  8 +++-----
> >   include/linux/blkdev.h | 10 ++++++++++
> >   3 files changed, 16 insertions(+), 11 deletions(-)
> > 
> > diff --git a/block/bio.c b/block/bio.c
> > index 21cbaa6a1c20..f67afa159de7 100644
> > --- a/block/bio.c
> > +++ b/block/bio.c
> > @@ -1069,18 +1069,15 @@ static void submit_bio_wait_endio(struct bio *bio)
> >   int submit_bio_wait(struct bio *bio)
> >   {
> >   	DECLARE_COMPLETION_ONSTACK_MAP(done, bio->bi_disk->lockdep_map);
> > -	unsigned long hang_check;
> > +	unsigned long timeout = blk_default_io_timeout();
> >   	bio->bi_private = &done;
> >   	bio->bi_end_io = submit_bio_wait_endio;
> >   	bio->bi_opf |= REQ_SYNC;
> >   	submit_bio(bio);
> > -	/* Prevent hang_check timer from firing at us during very long I/O */
> > -	hang_check = sysctl_hung_task_timeout_secs;
> > -	if (hang_check)
> > -		while (!wait_for_completion_io_timeout(&done,
> > -					hang_check * (HZ/2)))
> > +	if (timeout)
> > +		while (!wait_for_completion_io_timeout(&done, timeout))
> >   			;
> >   	else
> >   		wait_for_completion_io(&done);
> > diff --git a/block/blk-exec.c b/block/blk-exec.c
> > index e20a852ae432..17b5cf07e1a3 100644
> > --- a/block/blk-exec.c
> > +++ b/block/blk-exec.c
> > @@ -80,15 +80,13 @@ void blk_execute_rq(struct request_queue *q, struct gendisk *bd_disk,
> >   		   struct request *rq, int at_head)
> >   {
> >   	DECLARE_COMPLETION_ONSTACK(wait);
> > -	unsigned long hang_check;
> > +	unsigned long timeout = blk_default_io_timeout();
> >   	rq->end_io_data = &wait;
> >   	blk_execute_rq_nowait(q, bd_disk, rq, at_head, blk_end_sync_rq);
> > -	/* Prevent hang_check timer from firing at us during very long I/O */
> > -	hang_check = sysctl_hung_task_timeout_secs;
> > -	if (hang_check)
> > -		while (!wait_for_completion_io_timeout(&wait, hang_check * (HZ/2)));
> > +	if (timeout)
> > +		while (!wait_for_completion_io_timeout(&wait, timeout));
> >   	else
> >   		wait_for_completion_io(&wait);
> >   }
> This probably just shows my ignorance, but why don't we check for
> rq->timeout here?
> I do see that not all requests have a timeout, but what about those who
> have?

Here the IO means IO from upper layer(FS, user space, ...), and this
kind of IO isn't same with block layer's IO request which is splitted
from upper layer's bio.

So we can't apply the rq->timeout directly, especially we want to avoid
the task hung on the sync IO from upper layer.

Thanks,
Ming


  reply	other threads:[~2020-04-28  8:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28  7:46 [PATCH 0/2] block: prevent task hung from being triggered in sync dio Ming Lei
2020-04-28  7:46 ` [PATCH 1/2] block: add blk_default_io_timeout() for avoiding task hung in sync IO Ming Lei
2020-04-28  8:05   ` Hannes Reinecke
2020-04-28  8:30     ` Ming Lei [this message]
2020-04-28 14:19   ` Bart Van Assche
2020-04-29  1:17     ` Ming Lei
2020-04-30  3:08       ` Bart Van Assche
2020-05-03  1:43         ` Ming Lei
2020-04-28  7:46 ` [PATCH 2/2] block: add blk_io_schedule() for avoiding task hung in sync dio 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=20200428083047.GA624552@T590 \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jsbarnes@google.com \
    --cc=linux-block@vger.kernel.org \
    --cc=sqazi@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.