All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: "M. Vefa Bicakci" <bicave@superonline.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-pm@lists.linux-foundation.org
Subject: Re: [Bisected Regression in 2.6.35] A full tmpfs filesystem causeshibernation to hang
Date: Thu, 2 Sep 2010 00:02:24 +0200	[thread overview]
Message-ID: <201009020002.25113.rjw@sisk.pl> (raw)
In-Reply-To: <20100901093219.9744.A69D9226@jp.fujitsu.com>

On Wednesday, September 01, 2010, KOSAKI Motohiro wrote:
> > === 8< ===
> > PM: Marking nosave pages: ...0009f000 - ...000100000
> > PM: basic memory bitmaps created
> > PM: Syncing filesystems ... done
> > Freezing user space processes ... (elapsed 0.01 seconds) done.
> > Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.
> > PM: Preallocating image memory...
> > shrink_all_memory start
> > PM: shrink memory: pass=1, req:310171 reclaimed:15492 free:360936
> > PM: shrink memory: pass=2, req:294679 reclaimed:28864 free:373981
> > PM: shrink memory: pass=3, req:265815 reclaimed:60311 free:405374
> > PM: shrink memory: pass=4, req:205504 reclaimed:97870 free:443024
> > PM: shrink memory: pass=5, req:107634 reclaimed:146948 free:492141
> > shrink_all_memory: req:107634 reclaimed:146948 free:492141
> > PM: preallocate_image_highmem 556658 278329
> > PM: preallocate_image_memory 103139 103139
> > PM: preallocate_highmem_fraction 183908 556658 760831 -> 183908
> > === >8 ===
> 
> Rafael, this log mean hibernate_preallocate_memory() has a bug.

Well, it works as designed ...

> It allocate memory as following order.
>  1. preallocate_image_highmem()  (i.e. __GFP_HIGHMEM)
>  2. preallocate_image_memory()   (i.e. GFP_KERNEL)
>  3. preallocate_highmem_fraction (i.e. __GFP_HIGHMEM)
>  4. preallocate_image_memory()   (i.e. GFP_KERNEL)
> 
> But, please imazine following scenario (as Vefa's scenario).
>  - system has 3GB memory. 1GB is normal. 2GB is highmem.
>  - all normal memory is free
>  - 1.5GB memory of highmem are used for tmpfs. rest 500MB is free.

Indeed, that's a memory allocation pattern I didn't anticipate.

> At that time, hibernate_preallocate_memory() works as following.
> 
> 1. call preallocate_image_highmem(1GB)
> 2. call preallocate_image_memory(500M)		total 1.5GB allocated
> 3. call preallocate_highmem_fraction(660M)	total 2.2GB allocated
> 
> then, all of normal zone memory was exhaust. next preallocate_image_memory()
> makes OOM, and oom_killer_disabled makes infinite loop.
> (oom_killer_disabled careless is vmscan bug. I'll fix it soon)

So, it looks like the problem will go away if we check if there are any normal
pages to allocate from before calling the last preallocate_image_memory()?

Like in the patch below, perhaps?

> The problem is, alloc_pages(__GFP_HIGHMEM) -> alloc_pages(GFP_KERNEL) is
> wrong order. alloc_pages(__GFP_HIGHMEM) may allocate page from lower zone.
> then, next alloc_pages(GFP_KERNEL) lead to OOM.
> 
> Please consider alloc_pages(GFP_KERNEL) -> alloc_pages(__GFP_HIGHMEM) order.
> Even though vmscan fix can avoid infinite loop, OOM situation might makes
> big slow down on highmem machine. It seems no good.

There's a problem with the ordering change that it wouldn't be clear how many
pages to request from the normal zone in step 1 and 3.

Thanks,
Rafael 

---
 kernel/power/snapshot.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Index: linux-2.6/kernel/power/snapshot.c
===================================================================
--- linux-2.6.orig/kernel/power/snapshot.c
+++ linux-2.6/kernel/power/snapshot.c
@@ -1259,7 +1259,7 @@ int hibernate_preallocate_memory(void)
 {
 	struct zone *zone;
 	unsigned long saveable, size, max_size, count, highmem, pages = 0;
-	unsigned long alloc, save_highmem, pages_highmem;
+	unsigned long alloc, save_highmem, pages_highmem, size_normal;
 	struct timeval start, stop;
 	int error;
 
@@ -1296,6 +1296,7 @@ int hibernate_preallocate_memory(void)
 		else
 			count += zone_page_state(zone, NR_FREE_PAGES);
 	}
+	size_normal = count;
 	count += highmem;
 	count -= totalreserve_pages;
 
@@ -1344,7 +1345,13 @@ int hibernate_preallocate_memory(void)
 	size = preallocate_highmem_fraction(size, highmem, count);
 	pages_highmem += size;
 	alloc -= size;
-	pages += preallocate_image_memory(alloc);
+	/* Check if there are any non-highmem pages to allocate from. */
+	if (alloc_normal < size_normal) {
+		size_normal -= alloc_normal;
+		if (alloc > size_normal)
+			alloc = size_normal;
+		pages += preallocate_image_memory(alloc);
+	}
 	pages += pages_highmem;
 
 	/*

  parent reply	other threads:[~2010-09-01 22:04 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-15  5:25 [Bisected Regression in 2.6.35] A full tmpfs filesystem causes hibernationto hang M. Vefa Bicakci
2010-08-17  2:37 ` KOSAKI Motohiro
2010-08-22 11:06 ` KOSAKI Motohiro
2010-08-22 16:28   ` [Bisected Regression in 2.6.35] A full tmpfs filesystem causeshibernation to hang M. Vefa Bicakci
2010-08-25  8:55     ` KOSAKI Motohiro
2010-08-25 10:11       ` [Bisected Regression in 2.6.35] A full tmpfs filesystem causeshibernationto hang M. Vefa Bicakci
2010-08-25 17:31       ` [Bisected Regression in 2.6.35] A full tmpfs filesystem causeshibernation to hang Rafael J. Wysocki
2010-08-23  0:22   ` [Bisected Regression in 2.6.35] A full tmpfs filesystem causes hibernationto hang KOSAKI Motohiro
2010-08-23  6:27     ` [Bisected Regression in 2.6.35] A full tmpfs filesystem causeshibernation to hang M. Vefa Bicakci
2010-08-25  0:48       ` KOSAKI Motohiro
2010-08-25  8:39         ` KOSAKI Motohiro
2010-08-25 10:10           ` [Bisected Regression in 2.6.35] A full tmpfs filesystem causeshibernationto hang M. Vefa Bicakci
     [not found]           ` <4C74EB70.3080406@superonline.com>
     [not found]             ` <20100826134506.F676.A69D9226@jp.fujitsu.com>
2010-08-26 10:36               ` M. Vefa Bicakci
2010-08-30  2:28                 ` KOSAKI Motohiro
2010-08-30 16:54                   ` [Bisected Regression in 2.6.35] A full tmpfs filesystem causeshibernation to hang M. Vefa Bicakci
2010-08-31  6:35                     ` KOSAKI Motohiro
2010-08-31  6:54                       ` KOSAKI Motohiro
2010-08-31 11:25                         ` [Bisected Regression in 2.6.35] A full tmpfs filesystem causeshibernationto hang M. Vefa Bicakci
2010-09-01  0:48                     ` [Bisected Regression in 2.6.35] A full tmpfs filesystem causeshibernation to hang KOSAKI Motohiro
2010-09-01 22:02                       ` Rafael J. Wysocki
2010-09-01 22:02                       ` Rafael J. Wysocki [this message]
2010-09-02  0:31                         ` KOSAKI Motohiro
2010-09-02  0:31                         ` KOSAKI Motohiro
2010-09-02 19:57                           ` Rafael J. Wysocki
2010-09-02 19:57                           ` Rafael J. Wysocki
2010-09-02 20:24                             ` Rafael J. Wysocki
2010-09-02 20:24                               ` Rafael J. Wysocki
2010-09-03  0:13                               ` KOSAKI Motohiro
2010-09-03  0:13                               ` KOSAKI Motohiro
2010-09-03  1:07                                 ` Rafael J. Wysocki
2010-09-03  1:07                                   ` Rafael J. Wysocki
2010-09-03  1:53                                   ` KOSAKI Motohiro
2010-09-04  1:44                                     ` Rafael J. Wysocki
2010-09-04  1:44                                     ` Rafael J. Wysocki
2010-09-06  2:08                                       ` KOSAKI Motohiro
2010-09-06 11:27                                         ` Important news regarding the two different patches M. Vefa Bicakci
2010-09-06 18:43                                           ` Rafael J. Wysocki
2010-09-06 18:43                                           ` Rafael J. Wysocki
2010-09-07  1:34                                             ` M. Vefa Bicakci
2010-09-07  1:34                                             ` M. Vefa Bicakci
2010-09-07  1:58                                               ` KOSAKI Motohiro
2010-09-07 21:44                                                 ` Rafael J. Wysocki
2010-09-07 21:44                                                 ` Rafael J. Wysocki
2010-09-08 12:56                                                   ` M. Vefa Bicakci
2010-09-08 21:34                                                     ` [PATCH] PM / Hibernate: Avoid hitting OOM during preallocation of memory (was: Re: Important news ...) Rafael J. Wysocki
2010-09-11 18:12                                                       ` PATCH: PM / Hibernate: Avoid hitting OOM during preallocationof memory M. Vefa Bicakci
2010-09-11 18:12                                                       ` M. Vefa Bicakci
2010-09-11 19:06                                                         ` Rafael J. Wysocki
2010-09-11 19:06                                                         ` Rafael J. Wysocki
2010-09-11 22:27                                                           ` [PATCH] PM / Hibernate: Make default image size depend on total RAM size (was: Re: PATCH: PM / Hibernate: Avoid hitting OOM ...) Rafael J. Wysocki
2010-09-13 15:40                                                             ` [PATCH] PM / Hibernate: Make default image size depend on totalRAM size M. Vefa Bicakci
2010-09-13 15:40                                                             ` M. Vefa Bicakci
2010-09-13 17:52                                                               ` Rafael J. Wysocki
2010-09-13 17:52                                                               ` Rafael J. Wysocki
2010-09-11 22:27                                                           ` [PATCH] PM / Hibernate: Make default image size depend on total RAM size (was: Re: PATCH: PM / Hibernate: Avoid hitting OOM ...) Rafael J. Wysocki
2010-09-08 21:34                                                     ` [PATCH] PM / Hibernate: Avoid hitting OOM during preallocation of memory (was: Re: Important news ...) Rafael J. Wysocki
2010-09-08 12:56                                                   ` Important news regarding the two different patches M. Vefa Bicakci
2010-09-07  1:58                                               ` KOSAKI Motohiro
2010-09-06 11:27                                         ` M. Vefa Bicakci
2010-09-06 18:46                                         ` [Bisected Regression in 2.6.35] A full tmpfs filesystem causeshibernation to hang Rafael J. Wysocki
2010-09-06 19:54                                           ` Rafael J. Wysocki
2010-09-06 19:54                                           ` Rafael J. Wysocki
2010-09-06 18:46                                         ` Rafael J. Wysocki
2010-09-06  2:08                                       ` KOSAKI Motohiro
2010-09-03  1:53                                   ` KOSAKI Motohiro
2010-09-01  0:48                     ` KOSAKI Motohiro

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=201009020002.25113.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=bicave@superonline.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@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 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.