[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0gpaWSqf+V_NF8+H-w34tu-4dSvGz8Zfc7EKkpPZ2rd3g@mail.gmail.com>
Date: Tue, 7 Jan 2020 13:14:22 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Luigi Semenzato <semenzato@...gle.com>
Cc: Linux PM <linux-pm@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux Memory Management List <linux-mm@...ck.org>,
Andrew Morton <akpm@...ux-foundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Geoff Pike <gpike@...gle.com>, elliott@....com
Subject: Re: [PATCH v3 1/2] Documentation: clarify limitations of hibernation
On Fri, Jan 3, 2020 at 12:19 AM Luigi Semenzato <semenzato@...gle.com> wrote:
>
> Entering hibernation (suspend-to-disk) will fail if the kernel
> cannot allocate enough memory to create a snapshot of all pages
> in use; i.e., if memory in use is over 1/2 of total RAM. This
> patch makes this limitation clearer in the documentation. Without
> it, users may assume that hibernation can replace suspend-to-RAM
> when in fact its functionality is more limited.
>
> Signed-off-by: Luigi Semenzato <semenzato@...gle.com>
> ---
> Documentation/admin-guide/pm/sleep-states.rst | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/admin-guide/pm/sleep-states.rst b/Documentation/admin-guide/pm/sleep-states.rst
> index cd3a28cb81f4..a2d5632b7856 100644
> --- a/Documentation/admin-guide/pm/sleep-states.rst
> +++ b/Documentation/admin-guide/pm/sleep-states.rst
> @@ -112,7 +112,9 @@ Hibernation
> This state (also referred to as Suspend-to-Disk or STD) offers the greatest
> energy savings and can be used even in the absence of low-level platform support
> for system suspend. However, it requires some low-level code for resuming the
> -system to be present for the underlying CPU architecture.
> +system to be present for the underlying CPU architecture. Additionally, the
> +current implementation can enter the hibernation state only when memory
> +usage is sufficiently low (see "Limitations" below).
This really isn't about memory usage being "sufficiently low" (I told
you I could hibernate systems with almost 100% of RAM allocated before
hibernation), but about specific memory allocation patterns that may
prevent the hibernation code from being able to get enough memory on
demand.
So I would prefer the following alternative statement: "Additionally,
the hibernation state cannot be entered if the current memory usage
pattern of the system prevents the hibernation code from acquiring
enough memory (see "Limitations" below)."
> Hibernation is significantly different from any of the system suspend variants.
> It takes three system state changes to put it into hibernation and two system
> @@ -149,6 +151,14 @@ Hibernation is supported if the :c:macro:`CONFIG_HIBERNATION` kernel
> configuration option is set. However, this option can only be set if support
> for the given CPU architecture includes the low-level code for system resume.
>
> +Limitations of Hibernation
> +==========================
> +
> +When entering hibernation, the kernel tries to allocate a chunk of memory large
> +enough to contain a copy of all pages in use, to use it for the system
> +snapshot.
This isn't precise enough, because "all pages in use" may be read as
"all pages of virtual memory in use" and "a chunk of memory" may be
misunderstood as "a contiguous region".
The following describes what the code really does more precisely IMO:
"When entering hibernation, the kernel tries to allocate enough memory
to store a copy of every physical page frame (in RAM) that is not
free, except for some special regions of physical memory explicitly
marked as "not to be saved". These allocations are made one page at a
time with the expectation that the memory management subsystem will
push out memory to the swap when it is not able to find a free
physical page frame. However, in some cases that expectation is not
met: for example when there is not enough swap space in the system or
when the total amount of anonymous pages (process data) exceeds 1/2 of
total RAM. In those cases the operation fails with ENOMEM."
>+ If the allocation fails, the system cannot hibernate and the
> +operation fails with ENOMEM. This will happen, for instance, when the total
> +amount of anonymous pages (process data) exceeds 1/2 of total RAM.
>
> Basic ``sysfs`` Interfaces for System Suspend and Hibernation
> =============================================================
> --
> 2.24.1.735.g03f4e72817-goog
>
Powered by blists - more mailing lists