Re: [PATCH]: Compress hibernation image with LZO (in-kernel)

From: KAMEZAWA Hiroyuki
Date: Sun Aug 01 2010 - 21:32:44 EST


On Mon, 02 Aug 2010 11:21:08 +1000
Bojan Smojver <bojan@xxxxxxxxxxxxx> wrote:

> On Mon, 2010-08-02 at 10:10 +0900, KAMEZAWA Hiroyuki wrote:
> > Why swsusp can avoid memory leak is that it records which
> > pages should be freed after resume in the bitmap, which will be saved
> > to image header(?)
>
> Right. So, are you saying that all allocations in save_image() should be
> done using __get_free_page() or __get_free_pages() and not with
> vmalloc()?
>
I don't say so but a consideration about following is required.
(And it's good to write "we're safe because...as comment")

1. Information about pointers used for vmalloc are saved into image.
2. Information(1) is properly recovered after resume and we can free it.
3. No more allocation will happen once we start wriritng to the disk.

Then, vmalloc() area itself's information will be saved as
"this vmalloc area is used"

and, at resume, recoreved as
"this vmalloc area is used"

Then, you can free it because you remember pointers.

Then, you should make

@@ -372,6 +380,38 @@ static int save_image(struct swap_map_handle *handle,
struct bio *bio;
struct timeval start;
struct timeval stop;
+ size_t ul, cl;
+ unsigned char *unc, *cmp, *wrk, *page;

as global variable. Because global variables will be saved as it is,
you can find it after resume and free used vmalloc() buffers.

Maybe freeing it at swsusp_free() will be clean.


Thanks,
-Kame

--
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/