Re: hibernation memory usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Luigi,

(CC: +linux-pm mailing list)

On 03/10/2019 18:16, Luigi Semenzato wrote:
> I am working on a project that uses hibernation, and we've noticed occasional failures
> with "echo disk > /sys/power/state" returning ENOMEM.  I added some logging and noticed
> that the failures seem to correlate with total anonymous pages being approximately 1/2 of
> total RAM.  The allocation strategy isn't explicitly documented and the code is a bit
> tricky (as usual), but I am getting the sense that a copy of the entire RAM in use is made
> prior to saving it to disk.  Is it the case then that hibernation is guaranteed to fail if
> anon memory is more than 50% of RAM? 

I'm pretty sure it is. If 50% of memory needs saving, you can't create a snapshot of it.


> Since tasks are frozen, that memory cannot change> and the copy seems redundant (except it probably makes things simpler).

Tasks aren't the only thing changing memory. Hibernate save/restores the entire system,
including the kernel data and text. (what happens if a task is waiting for a syscall to
complete?)


Hibernate needs a snapshot of memory, and the disk drivers, block layer etc need to write
to memory (and allocate it) in order to get their work done.

To work with this, hibernate's create_image() stops secondary CPUs and suspends all
devices. Now that only hibernate is running, it calls swsusp_arch_suspend() which then
call swsusp_save(). This creates the snapshot of memory.

Once this is done, devices are thawed, and hibernate() goes on to call swusp_write() to
write the snapshot to disk. Finally, processes are thawed.

(create_image() is called by hibernation_snapshot() from hibernate()).


If you don't need to save/restore the kernel state, you might not need hibernate at all.


Thanks,

James





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux