From c3a93b865e76afd02bf3856c63c50dd9493afafd Mon Sep 17 00:00:00 2001 From: KOSAKI Motohiro 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