linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>,
	linux-pm@lists.linux-foundation.org,
	LKML <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [RFC][PATCH] PM: Force GFP_NOIO during suspend/resume (was: Re: [linux-pm] Memory allocations in .suspend became very unreliable)
Date: Mon, 18 Jan 2010 21:55:09 +0100	[thread overview]
Message-ID: <201001182155.09727.rjw@sisk.pl> (raw)
In-Reply-To: <20100118110324.AE30.A69D9226@jp.fujitsu.com>

On Monday 18 January 2010, KOSAKI Motohiro wrote:
> > Hi,
> > 
> > I thing the snippet below is a good summary of what this is about.
> > 
> > On Saturday 16 January 2010, Rafael J. Wysocki wrote:
> > > On Saturday 16 January 2010, Maxim Levitsky wrote:
> > > > On Sat, 2010-01-16 at 01:57 +0100, Rafael J. Wysocki wrote: 
> > > > > On Saturday 16 January 2010, Maxim Levitsky wrote:
> > > > > > On Fri, 2010-01-15 at 23:03 +0100, Rafael J. Wysocki wrote: 
> > > > > > > On Friday 15 January 2010, Maxim Levitsky wrote:
> > > > > > > > Hi,
> > > > > > > 
> > > > > > > Hi,
> > > > > > > 
> > > > > > > > I know that this is very controversial, because here I want to describe
> > > > > > > > a problem in a proprietary driver that happens now in 2.6.33-rc3
> > > > > > > > I am taking about nvidia driver.
> > > > > > > > 
> > > > > > > > Some time ago I did very long hibernate test and found no errors after
> > > > > > > > more that 200 cycles.
> > > > > > > > 
> > > > > > > > Now I update to 2.6.33 and notice that system will hand when nvidia
> > > > > > > > driver allocates memory is their .suspend functions. 
> > > > > > > 
> > > > > > > They shouldn't do that, there's no guarantee that's going to work at all.
> > > > > > > 
> > > > > > > > This could fail in 2.6.32 if I would run many memory hungry
> > > > > > > > applications, but now this happens with most of memory free.
> > > > > > > 
> > > > > > > This sounds a little strange.  What's the requested size of the image?
> > > > > > Don't know, but system has to be very tight on memory.
> > > > > 
> > > > > Can you send full dmesg, please?
> > > > 
> > > > I deleted it, but for this case I think that hang was somewhere else.
> > > > This task was hand on doing forking, which probably happened even before
> > > > the freezer.
> > > > 
> > > > Anyway, the problem is clear. Now __get_free_pages blocks more often,
> > > > and can block in .suspend even if there is plenty of memory free.
> > 
> > This is suspicious, but I leave it to the MM people for consideration.
> > 
> > > > I now patched nvidia to use GFP_ATOMIC _always_, and problem disappear.
> > > > It isn't such great solution when memory is tight though....
> > > > 
> > > > This is going to hit hard all nvidia users...
> > > 
> > > Well, generally speaking, no driver should ever allocate memory using
> > > GFP_KERNEL in its .suspend() routine, because that's not going to work, as you
> > > can readily see.  So this is a NVidia bug, hands down.
> > > 
> > > Now having said that, we've been considering a change that will turn all
> > > GFP_KERNEL allocations into GFP_NOIO during suspend/resume, so perhaps I'll
> > > prepare a patch to do that and let's see what people think.
> > 
> > If I didn't confuse anything (which is likely, because it's a bit late here
> > now), the patch below should do the trick.  I have only checked that it doesn't
> > break compilation, so please take it with a grain of salt.
> > 
> > Comments welcome.
> 
> Hmm..
> I don't think this is good idea.
> 
> GFP_NOIO mean "Please don't reclaim if the page is dirty". It mean the system
> have lots dirty pages, this patch might makes hung up.

The point is to prevent the mm subsystem from using I/O.  If there's a better
way, please tell me. :-)

> If suspend need lots memory, we need to make free memory before starting IO
> suspending, I think.

Suspend as such doesn't need a lot of memory, except for some drivers doing
things they shouldn't do.

However, there are a few problems that need to be addressed in general.

First, we can't really guarantee that there's a lot of free memory available
during suspend and some memory allocations are done indirectly, using
GFP_KERNEL (for example, when new kernel threads are started).  If one of
these is done during suspend and it happens to cause the mm subsystem to
start I/O on a suspended devices, the kernel will lock up.

Second, there may be a memory allocation in progress when suspend is started
that causes I/O to happen and races with the suspend process.  If the latter
wins the race, the I/O may be attempted on a suspended device and the kernel
will lock up.

My patch attempts to avoid these two problems as well as the problem with
drivers using GFP_KERNEL allocations during suspend which I admit might be
solved by reworking the drivers.

Thanks,
Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2010-01-18 20:54 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1263549544.3112.10.camel@maxim-laptop>
     [not found] ` <1263678289.4276.4.camel@maxim-laptop>
     [not found]   ` <201001162317.39940.rjw@sisk.pl>
2010-01-17  0:38     ` [RFC][PATCH] PM: Force GFP_NOIO during suspend/resume (was: Re: [linux-pm] Memory allocations in .suspend became very unreliable) Rafael J. Wysocki
2010-01-17  1:24       ` Oliver Neukum
2010-01-17 13:27         ` Rafael J. Wysocki
2010-01-17 13:36           ` Rafael J. Wysocki
2010-01-17 18:58           ` Benjamin Herrenschmidt
2010-01-17 23:00             ` Rafael J. Wysocki
2010-01-18  7:53               ` Oliver Neukum
2010-01-18 16:17                 ` [linux-pm] [RFC][PATCH] PM: Force GFP_NOIO during suspend/resume (was: " Alan Stern
2010-01-18 20:59                   ` Rafael J. Wysocki
2010-01-19 15:13                     ` Alan Stern
2010-01-18 20:56                 ` [RFC][PATCH] PM: Force GFP_NOIO during suspend/resume (was: Re: [linux-pm] " Rafael J. Wysocki
2010-01-18 21:55               ` Benjamin Herrenschmidt
2010-01-18 23:33                 ` Rafael J. Wysocki
2010-01-17 13:55       ` Rafael J. Wysocki
2010-01-17 16:21         ` [linux-pm] [RFC][PATCH] PM: Force GFP_NOIO during suspend/resume (was: " Minchan Kim
2010-01-17 16:23           ` Minchan Kim
2010-01-18  0:25           ` Rafael J. Wysocki
2010-01-18  2:20             ` KOSAKI Motohiro
2010-01-18 21:06               ` Rafael J. Wysocki
2010-01-19  9:15                 ` Oliver Neukum
2010-01-19 20:34                   ` Rafael J. Wysocki
2010-01-18 17:00         ` [RFC][PATCH] PM: Force GFP_NOIO during suspend/resume (was: Re: [linux-pm] " Oliver Neukum
2010-01-18 20:41           ` Rafael J. Wysocki
2010-01-19  9:25             ` Oliver Neukum
2010-01-19 20:37               ` Rafael J. Wysocki
2010-01-20 14:05                 ` Oliver Neukum
2010-01-20 21:13                   ` Rafael J. Wysocki
2010-01-18  2:16       ` KOSAKI Motohiro
2010-01-18 20:55         ` Rafael J. Wysocki [this message]
2010-01-19  1:19           ` KOSAKI Motohiro
2010-01-19  3:19             ` Benjamin Herrenschmidt
2010-01-19  9:04               ` Bastien ROUCARIES
2010-01-19 23:17                 ` Benjamin Herrenschmidt
2010-01-20 11:31                   ` Oliver Neukum
2010-01-20 21:11                     ` Benjamin Herrenschmidt
2010-01-20 21:12                     ` Rafael J. Wysocki
2010-01-19 20:47               ` Rafael J. Wysocki
2010-01-20  0:33                 ` KOSAKI Motohiro
2010-01-20 21:21                   ` Rafael J. Wysocki
2010-01-21  0:47                     ` KOSAKI Motohiro
2010-01-21 20:21                       ` Rafael J. Wysocki
2010-01-21 20:42                         ` [linux-pm] [RFC][PATCH] PM: Force GFP_NOIO during suspend/resume (was: " Nigel Cunningham
2010-01-21 21:38                           ` Rafael J. Wysocki
2010-01-22  1:31                         ` [RFC][PATCH] PM: Force GFP_NOIO during suspend/resume (was: Re: [linux-pm] " KOSAKI Motohiro
2010-01-22  1:42                           ` KOSAKI Motohiro
2010-01-22 10:11                             ` Maxim Levitsky
2010-01-22 21:19                               ` [Update][PATCH] MM / PM: Force GFP_NOIO during suspend/hibernation and resume Rafael J. Wysocki
2010-01-23  9:29                                 ` Maxim Levitsky
2010-01-25 21:49                                   ` Rafael J. Wysocki
2010-01-25 21:52                                     ` Alexey Starikovskiy
2010-01-30 18:56                                       ` Rafael J. Wysocki
2010-01-30 20:42                                         ` Maxim Levitsky
2010-01-30 20:53                                           ` Rafael J. Wysocki
2010-01-22 20:58                           ` [RFC][PATCH] PM: Force GFP_NOIO during suspend/resume (was: Re: [linux-pm] Memory allocations in .suspend became very unreliable) Rafael J. Wysocki
2010-01-30 15:46       ` Maxim Levitsky
2010-01-30 18:47         ` Rafael J. Wysocki
2010-01-30 20:37           ` Maxim Levitsky
2010-02-01 19:51             ` Maxim Levitsky

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=201001182155.09727.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=maximlevitsky@gmail.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;
as well as URLs for NNTP newsgroup(s).