mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: "M. Vefa Bicakci" <bicave@superonline.com>
Cc: kosaki.motohiro@jp.fujitsu.com,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [Bisected Regression in 2.6.35] A full tmpfs filesystem causeshibernation to hang
Date: Tue, 31 Aug 2010 15:35:32 +0900 (JST)	[thread overview]
Message-ID: <20100831091909.87C1.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <4C7BE25B.1020504@superonline.com>

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

> On 30/08/10 05:28 AM, KOSAKI Motohiro wrote:
> >> [snip]
> >>
> >> The interesting thing is that even though there is a lot of free memory at the
> >> end, it still hangs. 
> > 
> > Grr. I'm surprised this result ;-)
> > shrink_all_memory() finish to shrink memory successfully. but your
> > system still hang immediately after. I have no idea why this mysterious
> > occur. 
> > 
> > I prepared next debugging patch. It added prenty debug printk. I hope
> > it enlighten up which path makes system hang-up.
> > 
> > 1. apply my new patch
> > 
> > 2. Enable following PM debug option in Kconfig
> > 
> >   [*] Power Management support
> >   [*]   Power Management Debug Support
> >   [*]     Extra PM attributes in sysfs for low-level debugging/testing
> >   [*]     Verbose Power Management debugging
> > 
> > 3. append following kernel boot option into grub configration file
> > 
> > 	no_console_suspend=1
> > 
> > 3. kernel build and reboot
> > 4. some prepare
> >    # echo 8 > /proc/sysrq-trigger
> >    # cd /sys/power
> >    # echo 1 > pm_trace
> >    # echo 0 > pm_async
> > 
> > 5. run your test program
> > 
> > 
> >> I also included the timestamps; note the one and two second
> >> delays between the passes.
> > 
> > This is expected result because tmpfs shrink need swap-out. then
> > we need i/o time.
> > 
> >>
> >> Please let me know if there is anything I can do.
> > 
> > Please send me your .config and full dmesg.
> > 
> > 
> > Thanks many and many help us!
> 
> Hello,
> 
> I have followed your instructions, with one exception: I have also
> enabled CONFIG_PM_TRACE so that I would have /sys/power/pm_trace.
> 
> This time I had some more output, as expected. I double checked what
> I typed while looking at the screen-shot I took with my camera. Here's
> the output:
> 
> === 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 ===
> 
> According to your patch, the next output should have been
> "preallocate_image_memory ...", but it never gets printed, so the
> hang point should be that function.

Great!
I've attached more verbose debug message patch and trial bug fixing patch.
Could you please to try this?



> I am attaching my dmesg output which I got after the failed hibernation
> attempt and my .config file. Please note that the attached .config file
> is a trimmed version of the .config I usually use on my computer. I trimmed
> it so that it compiles faster, but (mostly) has support for devices I might
> use.
> 
> Thanks a lot for your help, and please let me know if I can do anything else.
> 


[-- Attachment #2: 0001-debug2.patch --]
[-- Type: application/octet-stream, Size: 5261 bytes --]

From c3a93b865e76afd02bf3856c63c50dd9493afafd Mon Sep 17 00:00:00 2001
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Date: Tue, 31 Aug 2010 13:10:15 +0900
Subject: [PATCH 1/2] debug2

---
 kernel/power/snapshot.c |   66 ++++++++++++++++++++++++++++------------------
 1 files changed, 40 insertions(+), 26 deletions(-)

diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index c864806..3144ab4 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -1258,10 +1258,13 @@ static unsigned long minimum_image_size(unsigned long saveable)
 int hibernate_preallocate_memory(void)
 {
 	struct zone *zone;
-	unsigned long saveable, size, max_size, count, highmem, pages = 0;
+	unsigned long saveable, max_size, count, highmem, pages = 0;
 	unsigned long alloc, save_highmem, pages_highmem;
 	struct timeval start, stop;
 	int error;
+	unsigned long additional_size, img_size;
+	unsigned long pages_fraction;
+	unsigned long img_pages;
 
 	printk(KERN_INFO "PM: Preallocating image memory... \n");
 	do_gettimeofday(&start);
@@ -1288,9 +1291,9 @@ int hibernate_preallocate_memory(void)
 	count = saveable;
 	saveable += save_highmem;
 	highmem = save_highmem;
-	size = 0;
+	additional_size = 0;
 	for_each_populated_zone(zone) {
-		size += snapshot_additional_pages(zone);
+		additional_size += snapshot_additional_pages(zone);
 		if (is_highmem(zone))
 			highmem += zone_page_state(zone, NR_FREE_PAGES);
 		else
@@ -1299,16 +1302,23 @@ int hibernate_preallocate_memory(void)
 	count += highmem;
 	count -= totalreserve_pages;
 
+	printk(KERN_INFO "PM: save_highmem(%lu), saveable(%lu) count=(%lu)\n",
+	       save_highmem, saveable, count);
+
 	/* Compute the maximum number of saveable pages to leave in memory. */
-	max_size = (count - (size + PAGES_FOR_IO)) / 2 - 2 * SPARE_PAGES;
-	size = DIV_ROUND_UP(image_size, PAGE_SIZE);
-	if (size > max_size)
-		size = max_size;
+	max_size = (count - (additional_size + PAGES_FOR_IO)) / 2 - 2 * SPARE_PAGES;
+	img_size = DIV_ROUND_UP(image_size, PAGE_SIZE);
+	if (img_size > max_size)
+		img_size = max_size;
+
+	printk(KERN_INFO "PM: max_size(%lu), image_size(%lu), img_size(%lu)\n",
+	       max_size, image_size, img_size);
+
 	/*
 	 * If the maximum is not less than the current number of saveable pages
 	 * in memory, allocate page frames for the image and we're done.
 	 */
-	if (size >= saveable) {
+	if (img_size >= saveable) {
 		printk(KERN_INFO "PM: size >= saveable. skip \n");
 		pages = preallocate_image_highmem(save_highmem);
 		pages += preallocate_image_memory(saveable - pages);
@@ -1316,9 +1326,12 @@ int hibernate_preallocate_memory(void)
 	}
 
 	/* Estimate the minimum size of the image. */
-	pages = minimum_image_size(saveable);
-	if (size < pages)
-		size = min_t(unsigned long, pages, max_size);
+	img_pages = minimum_image_size(saveable);
+	if (img_size < img_pages)
+		img_size = min_t(unsigned long, img_pages, max_size);
+
+	printk(KERN_INFO "PM: img_pages(%lu), img_size(%lu)\n",
+	       img_pages, img_size);
 
 	/*
 	 * Let the memory management subsystem know that we're going to need a
@@ -1326,7 +1339,7 @@ int hibernate_preallocate_memory(void)
 	 * NOTE: If this is not done, performance will be hurt badly in some
 	 * test cases.
 	 */
-	shrink_all_memory(saveable - size);
+	shrink_all_memory(saveable - img_size);
 
 	/*
 	 * The number of saveable pages in memory was too high, so apply some
@@ -1336,30 +1349,31 @@ int hibernate_preallocate_memory(void)
 	 * highmem and non-highmem zones separately.
 	 */
 	pages_highmem = preallocate_image_highmem(highmem / 2);
-	printk(KERN_INFO "PM: preallocate_image_highmem %lu %lu\n",
-	       highmem, pages_highmem);
+	printk(KERN_INFO "PM: preallocate_image_highmem %lu %lu free(%u/%lu)\n",
+	       highmem, pages_highmem, nr_free_highpages(), global_page_state(NR_FREE_PAGES));
 
 	alloc = (count - max_size) - pages_highmem;
 	pages = preallocate_image_memory(alloc);
-	printk(KERN_INFO "PM: preallocate_image_memory %lu %lu\n",
-	       alloc, pages);
+	printk(KERN_INFO "PM: preallocate_image_memory %lu %lu free(%u/%lu)\n",
+	       alloc, pages, nr_free_highpages(), global_page_state(NR_FREE_PAGES));
 
 	if (pages < alloc) {
 		printk(KERN_INFO "PM: pages(%lu) < alloc(%lu). error. \n",
 		       pages, alloc);
 		goto err_out;
 	}
-	size = max_size - size;
-	alloc = size;
-	size = preallocate_highmem_fraction(size, highmem, count);
-	printk(KERN_INFO "PM: preallocate_highmem_fraction %lu %lu %lu -> %lu\n",
-	       size, highmem, count, size);
-
-	pages_highmem += size;
-	alloc -= size;
+
+	alloc = max_size - img_size;
+
+	pages_fraction = preallocate_highmem_fraction(alloc, highmem, count);
+	printk(KERN_INFO "PM: preallocate_highmem_fraction %lu %lu %lu -> %lu free(%u/%lu)\n",
+	       alloc, highmem, count, pages_fraction, nr_free_highpages(), global_page_state(NR_FREE_PAGES));
+
+	pages_highmem += pages_fraction;
+	alloc -= pages_fraction;
 	pages += preallocate_image_memory(alloc);
-	printk(KERN_INFO "PM: preallocate_image_memory %lu %lu\n",
-	       alloc, pages);
+	printk(KERN_INFO "PM: preallocate_image_memory %lu %lu free(%u/%lu)\n",
+	       alloc, pages, nr_free_highpages(), global_page_state(NR_FREE_PAGES));
 	pages += pages_highmem;
 
 	/*
-- 
1.6.5.2


[-- Attachment #3: 0002-add-gfp_noretry.patch --]
[-- Type: application/octet-stream, Size: 825 bytes --]

From 561bf4eed48ce99bd8d8b933390603f84ac4cacb Mon Sep 17 00:00:00 2001
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Date: Tue, 31 Aug 2010 14:58:04 +0900
Subject: [PATCH 2/2] add gfp_noretry

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
 kernel/power/snapshot.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 3144ab4..c488704 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -1091,7 +1091,7 @@ void swsusp_free(void)
 
 /* Helper functions used for the shrinking of memory. */
 
-#define GFP_IMAGE	(GFP_KERNEL | __GFP_NOWARN)
+#define GFP_IMAGE	(GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY)
 
 /**
  * preallocate_image_pages - Allocate a number of pages for hibernation image
-- 
1.6.5.2


  reply	other threads:[~2010-08-31  6:35 UTC|newest]

Thread overview: 42+ 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 [this message]
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-02  0:31                         ` KOSAKI Motohiro
2010-09-02 19:57                           ` Rafael J. Wysocki
2010-09-02 20:24                             ` Rafael J. Wysocki
2010-09-03  0:13                               ` KOSAKI Motohiro
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-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-07  1:34                                             ` M. Vefa Bicakci
2010-09-07  1:58                                               ` KOSAKI Motohiro
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 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 17:52                                                               ` Rafael J. Wysocki
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

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=20100831091909.87C1.A69D9226@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=bicave@superonline.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®