Re: Memory consumption difference between in-kernel and userspace hibernation

Rafael J. Wysocki
2009-11-13T16:28:32Z

On Friday 13 November 2009, Thomas Petazzoni wrote:
> Hello,
>
> Le Thu, 12 Nov 2009 21:01:55 +0100,
> Thomas Petazzoni <thomas.petazzoni@free-electrons.com> a écrit :
>
> > Question: is there any difference in terms of memory requirements for
> > the in-kernel hibernation (echo disk > /sys/power/state) and the
> > userspace hibernation interface (through /dev/snapshot) ? With exactly
> > the same userspace workload and applications running, the in-kernel
> > hibernation works, but the hibernating using the userspace hibernation
> > interface fails because not enough memory can be freed.
>
> The difference is that when using the in-kernel solution, a swap is
> enabled, and it seems that it allows the kernel to free some memory in
> order to create the snapshot.

Yes, it does.

> But I don't understand why : won't the swap contents be completely
> erased when the resume image will be written to it, and therefore all
> the things migrated to the swap when freing the memory would be lost ?

No, the kernel doesn't use the swap space already in use for saving the
image. Also, s2disk uses the kernel for allocating swap space in which to
save the image, so it avoids overwriting the swap space in use too.

Thanks,
Rafael