linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Tony Battersby <tonyb@cybernetics.com>,
	linux-raid@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>,
	axboe@kernel.dk, Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: RAID1 might_sleep() warning on 3.19-rc7
Date: Tue, 10 Feb 2015 13:50:17 +1100	[thread overview]
Message-ID: <20150210135017.7659e49c@notabene.brown> (raw)
In-Reply-To: <20150209091000.GN5029@twins.programming.kicks-ass.net>

[-- Attachment #1: Type: text/plain, Size: 2464 bytes --]

On Mon, 9 Feb 2015 10:10:00 +0100 Peter Zijlstra <peterz@infradead.org> wrote:

> On Mon, Feb 09, 2015 at 12:13:57PM +1100, NeilBrown wrote:
> > I had to re-read the code (And your analysis) a couple of times to be sure ...
> 
> Sorry :-)

My point was that actually reading it (rather than assuming I knew what it
said) actually helped!

> 
> > However, when io_schedule() explicitly calls blk_flush_plug(), then
> > @from_schedule=false variant is used, and the unplug functions are allowed to
> > allocate memory and block and maybe even call mempool_alloc() which might
> > call io_schedule().
> > 
> > This shouldn't be a problem as blk_flush_plug() spliced out the plug list, so
> > any recursive call will find an empty list and do nothing.
> 
> Unless, something along the way stuck something back on, right? So
> should we stick an:
> 
> 	WARN_ON(current->in_iowait);
> 
> somewhere near where things are added to this plug list? (and move the
> blk_flush_plug() call inside of where that's actually true of course).

No, I don't think so.

It is certainly possible that some request on plug->cb_list could add
something to plug->list - which is processed after ->cb_list.

I think the best way to think about this is that the *problem* was that a
wait_event loop could spin without making any progress.   So any time that
clear forward progress is made it is safe sleep without necessitating the
warning.  Hence sched_annotate_sleep() is reasonable.
blk_flush_plug() with definitely have dispatched some requests if it
might_sleep(), so the sleep is OK.


> 
> The only thing that really goes wrong then is if people 'forget' to put
> a loop around io_schedule().

You mean like in congestion_wait() ??

Though that is mostly called inside a loop...


NeilBrown

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 92f4b4b288dd..7334be27823d 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1111,6 +1111,14 @@ static inline void blk_flush_plug(struct task_struct *tsk)
 {
 	struct blk_plug *plug = tsk->plug;
 
+	/*
+	 * Any sleeping in blk_flush_plug() should not
+	 * trigger the "do not call blocking ops" warning
+	 * as it makes clear forward process (requests are
+	 * dispatched) and so it will not cause indefinite
+	 * looping in a higher level wait loop.
+	 */
+	sched_annotate_sleep();
 	if (plug)
 		blk_flush_plug_list(plug, false);
 }

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

  reply	other threads:[~2015-02-10  2:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-05 20:27 RAID1 might_sleep() warning on 3.19-rc7 Tony Battersby
2015-02-05 21:51 ` NeilBrown
2015-02-06 11:39   ` Peter Zijlstra
2015-02-09  1:13     ` NeilBrown
2015-02-09  9:10       ` Peter Zijlstra
2015-02-10  2:50         ` NeilBrown [this message]
2015-02-10  9:29           ` Peter Zijlstra
2015-02-10 11:01             ` Peter Zijlstra
2015-02-13  5:26             ` NeilBrown
2015-02-13  8:32               ` Peter Zijlstra
2015-02-13  8:49                 ` NeilBrown
2015-02-13 10:27                   ` Peter Zijlstra
2015-02-13 14:48                     ` Peter Zijlstra
2015-02-18  1:09                       ` NeilBrown
2015-02-18 13:47                         ` Peter Zijlstra

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=20150210135017.7659e49c@notabene.brown \
    --to=neilb@suse.de \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tonyb@cybernetics.com \
    --cc=torvalds@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).