Re: [PATCH][1/3] mm: swsusp shrink_all_memory tweaks

From: Rafael J. Wysocki
Date: Mon Mar 20 2006 - 13:45:25 EST


On Monday 20 March 2006 12:50, Con Kolivas wrote:
> On Monday 20 March 2006 22:41, Nick Piggin wrote:
> > I still don't like this change.
>
> Fine.
>
> Respin.
}-- snip --{
> Index: linux-2.6.16-rc6-mm2/kernel/power/swsusp.c
> ===================================================================
> --- linux-2.6.16-rc6-mm2.orig/kernel/power/swsusp.c 2006-03-20 22:44:10.000000000 +1100
> +++ linux-2.6.16-rc6-mm2/kernel/power/swsusp.c 2006-03-20 22:46:12.000000000 +1100
> @@ -173,9 +173,6 @@ void free_all_swap_pages(int swap, struc
> * Notice: all userland should be stopped before it is called, or
> * livelock is possible.
> */
> -
> -#define SHRINK_BITE 10000
> -
> int swsusp_shrink_memory(void)
> {
> long size, tmp;
> @@ -194,14 +191,13 @@ int swsusp_shrink_memory(void)
> for_each_zone (zone)
> if (!is_highmem(zone))
> tmp -= zone->free_pages;
> + if (tmp <= 0)
> + tmp = size - image_size / PAGE_SIZE;
> if (tmp > 0) {
> - tmp = shrink_all_memory(SHRINK_BITE);
> + tmp = shrink_all_memory(tmp);
> if (!tmp)
> return -ENOMEM;
> pages += tmp;
> - } else if (size > image_size / PAGE_SIZE) {
> - tmp = shrink_all_memory(SHRINK_BITE);
> - pages += tmp;
> }
> printk("\b%c", p[i++%4]);
> } while (tmp > 0);
>

swsusp_shrink_memory() is still wrong, because it will always fail for
image_size = 0. My bad, sorry.

The appended patch (on top of yours) should fix that (hope I did it right
this time).

kernel/power/swsusp.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)

Index: linux-2.6.16-rc6-mm2/kernel/power/swsusp.c
===================================================================
--- linux-2.6.16-rc6-mm2.orig/kernel/power/swsusp.c
+++ linux-2.6.16-rc6-mm2/kernel/power/swsusp.c
@@ -192,13 +192,17 @@ int swsusp_shrink_memory(void)
for_each_zone (zone)
if (!is_highmem(zone))
tmp -= zone->free_pages;
- if (tmp <= 0)
- tmp = size - image_size / PAGE_SIZE;
if (tmp > 0) {
tmp = shrink_all_memory(tmp);
if (!tmp)
return -ENOMEM;
pages += tmp;
+ } else {
+ size -= image_size / PAGE_SIZE;
+ if (size > 0) {
+ tmp = shrink_all_memory(size);
+ pages += tmp;
+ }
}
printk("\b%c", p[i++%4]);
} while (tmp > 0);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/