From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35BD2C33CA1 for ; Tue, 7 Jan 2020 12:14:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D13362080A for ; Tue, 7 Jan 2020 12:14:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D13362080A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5D6E78E002B; Tue, 7 Jan 2020 07:14:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 585C28E001E; Tue, 7 Jan 2020 07:14:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C4638E002B; Tue, 7 Jan 2020 07:14:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0059.hostedemail.com [216.40.44.59]) by kanga.kvack.org (Postfix) with ESMTP id 362EF8E001E for ; Tue, 7 Jan 2020 07:14:35 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id CDDB052D6 for ; Tue, 7 Jan 2020 12:14:34 +0000 (UTC) X-FDA: 76350731268.10.apple03_27ede02a7a012 X-HE-Tag: apple03_27ede02a7a012 X-Filterd-Recvd-Size: 6230 Received: from mail-oi1-f195.google.com (mail-oi1-f195.google.com [209.85.167.195]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jan 2020 12:14:34 +0000 (UTC) Received: by mail-oi1-f195.google.com with SMTP id c77so17094461oib.7 for ; Tue, 07 Jan 2020 04:14:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=t2wJ0fJXfZgRbl2tNM1OvC++nsuOLsTnBLRuZM1DuX4=; b=ku0q6YWg8ODimJ178qDMLMT5hQABu5ocAiB6GoLC6dr69hSi4b7MjNpqEn31KUf+Gn CnU2aT/sQLaDmGIU3FD+SjlHZMwrMf6xBsIZ/6CWLDX8sBUuqKbcAkW78M+UqixRYxh+ DBs40umDEiAtrt730g/0o/gA5F6QKPtlYqeu3R9Zulamjpu41RJUCUNhREs5XxkkhIqB je8IaP/dtWZc0S30KdVJdkjkEmr0+78YILwwqcsxi1fy+4zsEcddwwr8z3IAmaH8J5v5 JngEJqqQ3oDHGGs6+twt9UcQpNBul53yLUN7B0sKfHptG8L2SsnmEECIqtHM6H0BWI+U koyg== X-Gm-Message-State: APjAAAXn56391TvUFti4oFe6D6m3aVJmtRDUrE7+T/Oexr22b05X2QeU JqVCvDok+uYShFda/WNiU/VgC+xT1cKxYwlh48Y= X-Google-Smtp-Source: APXvYqz3WOWxsLHYg3F5eRfLXAY9lctkzltccKEWDiLVvsIFT+exQHsyxgvza3mOZXY11FLK9TqrQXcvgzLbmomrUEc= X-Received: by 2002:aca:d6c8:: with SMTP id n191mr7335252oig.103.1578399273587; Tue, 07 Jan 2020 04:14:33 -0800 (PST) MIME-Version: 1.0 References: <20200102231940.202896-1-semenzato@google.com> <20200102231940.202896-2-semenzato@google.com> In-Reply-To: <20200102231940.202896-2-semenzato@google.com> From: "Rafael J. Wysocki" Date: Tue, 7 Jan 2020 13:14:22 +0100 Message-ID: Subject: Re: [PATCH v3 1/2] Documentation: clarify limitations of hibernation To: Luigi Semenzato Cc: Linux PM , Linux Kernel Mailing List , Linux Memory Management List , Andrew Morton , "Rafael J. Wysocki" , Geoff Pike , elliott@hpe.com Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Jan 3, 2020 at 12:19 AM Luigi Semenzato 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 > --- > 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 >