Messages in this thread Patch in this message | | | From | "Rafael J. Wysocki" <> | Subject | Re: [RFC/RFT][PATCH -mm] swsusp: improve memory shrinking | Date | Mon, 27 Feb 2006 00:38:40 +0100 |
| |
On Monday 27 February 2006 00:32, Rafael J. Wysocki wrote: > On Sunday 26 February 2006 19:53, Pavel Machek wrote: > > > > > > I did try shrink_all_memory() five times, with .5 second delay between > > > > > > them, and it freed more memory at later tries. > > > > > > > > > > I wonder if the delays are essential or if so, whether they may be shorter > > > > > than .5 sec. > > > > > > > > I was using this with some success... (Warning, against old > > > > kernel). But, as I said, I consider it ugly, and it would be better to > > > > fix shrink_all_memory. > > > > > > Appended is a patch against the current -mm. > > > [It also makes > > > swsusp_shrink_memory() behave as documented for image_size = 0. > > > Currently, if it states there's enough free RAM to suspend, it won't bother > > > to free a single page.] > > > > Could we get bugfix part separately? > > Sure. Appended is the bugfix (I haven't tested it separately yet, but I think > it's simple enough) ...
... and this is the workaround of the "shrink_all_memory() returns 0 prematurely" problem (not tested separately yet). [Together these patches make my box actually free more memory when image_size = 0.]
--- Make swsusp_shrink_memory() try harder to free more RAM if necessary or if the anticipated size of the image is greater than image_size.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> --- kernel/power/swsusp.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-)
Index: linux-2.6.16-rc4-mm2/kernel/power/swsusp.c =================================================================== --- linux-2.6.16-rc4-mm2.orig/kernel/power/swsusp.c 2006-02-27 00:25:34.000000000 +0100 +++ linux-2.6.16-rc4-mm2/kernel/power/swsusp.c 2006-02-27 00:28:58.000000000 +0100 @@ -175,6 +175,8 @@ void free_all_swap_pages(int swap, struc */ #define SHRINK_BITE 10000 +#define SHRINK_RETRY 3 +#define SHRINK_SLEEP 100 int swsusp_shrink_memory(void) { @@ -182,6 +184,7 @@ int swsusp_shrink_memory(void) struct zone *zone; unsigned long pages = 0; unsigned int i = 0; + int retry = SHRINK_RETRY; char *p = "-\\|/"; printk("Shrinking memory... "); @@ -200,8 +203,14 @@ int swsusp_shrink_memory(void) if (freed > 0) { pages += freed; tmp = freed; - } else if (tmp > 0) { - return -ENOMEM; + retry = SHRINK_RETRY; + } else { + if (--retry) { + msleep_interruptible(SHRINK_SLEEP); + tmp = size; + } else if (tmp > 0) { + return -ENOMEM; + } } } printk("\b%c", p[i++%4]); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |