Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3684376ybl; Mon, 27 Jan 2020 08:29:47 -0800 (PST) X-Google-Smtp-Source: APXvYqwpvbXHiiZGH6icIZtsCuOzKpKHl++H9Fv0/aZB/YDETSglaiHfIWNhAgSWbVeUCI2rbcx2 X-Received: by 2002:aca:f584:: with SMTP id t126mr1703992oih.132.1580142587352; Mon, 27 Jan 2020 08:29:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580142587; cv=none; d=google.com; s=arc-20160816; b=o8ZicphL48PbcAfIG9IJ00CKke1IqGXRH5T7z9XwScXj2jFy/4vbMZtOoxtXSEKGWB QXHlCISOhwDXGNZMuSwOgTQZbgqo+K9jUHNkUpoLafJne1XQTfvdLF5fyaE/erUCaXjO uLxMCIxr0Q8odIMmC0d5cDiAb6D7rM3UaphEOFQolmlNtgPxy03DDJxMSoNpaeCkYoGm n8lL6r26i20YEf9Lj4ZR0W6pJIzc458vek9AS9z8DwbCfZ3lTEpfdaP8uFTdmxgzvEpX RtUJk/+QmEAz0UeNrvbj00Tcj8ZM7pDergpfkxBpBGCv8pAqbpikRnjpx5ojjaXZwDUN DFyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=Jk0WC+x0mPaz/vAe6MTjly0FnoGTyiMYbm4PE77IrJc=; b=l3OcL5d+kwxF4sWFRwJcXqQwLMRNd7WfHSTpC0SMmXyHwjwaOEknnJskISQQU9Ora5 5EwazSfS98Wwo6Z9mJ80CGfLYknUO+Lw3/jhBUcXOnWoeMS1CGByNHIJ4IAAP4RYeja2 LJiEMuZdb2/0ppF11YuteDy73AbKqZyVLfgh64PUjq/mHbyGWKCLX7qK57czF/AWJ5d3 qqDG1MkWUkNTGvXExnVgNkEJwHoTb8K4Dvv9QvV/JNHlsX8Ic2H1UAEDayhurMySEruK TKRYEo1JAzHGdRQ0elfj8LvFGXLvjVDuc14tG1uMhCH6vxiF3wik41+DnBBFOvkKih5S 2q9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q6si6442398otf.301.2020.01.27.08.29.34; Mon, 27 Jan 2020 08:29:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726871AbgA0Q2g (ORCPT + 99 others); Mon, 27 Jan 2020 11:28:36 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:42080 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726101AbgA0Q2f (ORCPT ); Mon, 27 Jan 2020 11:28:35 -0500 Received: by mail-ot1-f68.google.com with SMTP id 66so8928309otd.9 for ; Mon, 27 Jan 2020 08:28:35 -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=Jk0WC+x0mPaz/vAe6MTjly0FnoGTyiMYbm4PE77IrJc=; b=SWZCYwqmNH75/clCB35GTMD/2yo3whM9xW2MykmuPH67CtgfVmA1EbX/KEe1tiAcmR +TctnH/LllTT5YWMrwRMLwt9Sw5ga+NTu6B/nnnJrae2zWaThZqt17S0qD3+SsaGi5pP TwPtPfph7dojv/d5MkM3wbAAv50OiDmUQjFxn7eVLf6tr67JuboLY4WhRXzKeBB8vxwa I7U+czNu4JjLe1yv0YaOeLqO0tu4ye8PnrjNk2tR/mPbh3/Hn8ysVV1lYyQO9/709w+5 XWJQur7zyGuA0P7BKznoQ9fnRwjA1W5FMiW/bI3ck9rM/gBGR96pHcw0s+zqY6LMkJQ6 +Ibg== X-Gm-Message-State: APjAAAUwrNxhDqcmiLJWFRs4xNy77o4f6MiXtARl3LXcTvxuJT2sbdhZ o3eT63cIr/Lug3aRgEvG5GQi2N9YcrnoQdBS4E0= X-Received: by 2002:a9d:62c7:: with SMTP id z7mr12712154otk.189.1580142515134; Mon, 27 Jan 2020 08:28:35 -0800 (PST) MIME-Version: 1.0 References: <20191226220205.128664-1-semenzato@google.com> <20191226220205.128664-2-semenzato@google.com> <20200106125352.GB9198@dhcp22.suse.cz> <20200108114952.GR32178@dhcp22.suse.cz> <20200127141637.GL1183@dhcp22.suse.cz> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 27 Jan 2020 17:28:24 +0100 Message-ID: Subject: Re: [PATCH 1/2] Documentation: clarify limitations of hibernation To: Luigi Semenzato Cc: Michal Hocko , Linux Memory Management List , linux-kernel , "Rafael J. Wysocki" , Andrew Morton , Geoff Pike Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 27, 2020 at 5:13 PM Luigi Semenzato wrote: > > On Mon, Jan 27, 2020 at 6:16 AM Michal Hocko wrote: > > > > On Fri 24-01-20 08:37:12, Luigi Semenzato wrote: > > [...] > > > The purpose of my documentation patch was to make it clearer that > > > hibernation may fail in situations in which suspend-to-RAM works; for > > > instance, when there is no swap, and anonymous pages are over 50% of > > > total RAM. I will send a new version of the patch which hopefully > > > makes this clearer. > > > > I was under impression that s2disk is pretty much impossible without any > > swap. > > I am not sure what you mean by "swap" here. S2disk needs a swap > partition for storing the image, but that partition is not used for > regular swap. That's not correct. The swap partition (or file) used by s2disk needs to be made active before it can use it and the mm subsystem is also able to use it for regular swap then. > If there is no swap, but more than 50% of RAM is free > or reclaimable, s2disk works fine. If anonymous is more than 50%, > hibernation can still work, but swap needs to be set up (in addition > to the space for the hibernation image). The setup is not obvious and > I don't think that the documentation is clear on this. Well, the entire contents of RAM must be preserved, this way or another, during hibernation. That should be totally obvious to anyone using it really. Some of the RAM contents is copies of data already there in the filesystems on persistent storage and that does not need to be saved again. Everything else must be saved and s2disk (and Linux hibernation in general) uses active swap space to save these things. This implies that in order to hibernate the system, you generally need the amount of swap space equal to the size of RAM minus the size of files mapped into memory. So, to be on the safe side, the total amount of swap space to be used for hibernation needs to match the size of RAM (even though realistically it may be smaller than that in the majority of cases).