Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2183353ybl; Thu, 30 Jan 2020 12:51:20 -0800 (PST) X-Google-Smtp-Source: APXvYqzrb4QFjxQrBaiYIABbk+Fvi8Wk2Kop+YwkfBsF7fUIfhXMhAUuMEHBauaTkMHMJDd1gx6L X-Received: by 2002:a05:6830:10d5:: with SMTP id z21mr5314464oto.30.1580417480069; Thu, 30 Jan 2020 12:51:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580417480; cv=none; d=google.com; s=arc-20160816; b=AgztfxwppcoV4O5cgzUPbUZL/FUIFxvuH4A2xhcmMZhTIRnLwTS9xF3KlhbonEnuQ3 pwt+KnRps7RtJ+xDfuyRYoFRmwcLYmHWKzd3HpTFHLEJ0e7vKWU2cx6Q1fEJrKM1CdKy 5lODhbIpGHgA6k5eLimj2iFZaFjxD6ATOfctWtYN7hQSHFEGQW4IbR3SatNYW3J24PWP 4sBUEB68qfINIHNbzmZFwNeuVw//uZqn2yDArbU4bXKL65t1tNnYbtMtJzz9Dl/AhC79 e0eOci4SFTBxYxGGTVcqrghZ0JN+YbFi4P7P3rEQW+J+RymA/nsyjd6tGKB/Twa0ZPfS bqQA== 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=Z08RuybXoEe11iM07MN6xxLwPZjJpKeFz19KOn5eV6I=; b=xNEchlDDFZisNrb4tUq1cstZ5ZFJX7yxy89sU/zC3ERM00VQMfB+cfGPCs1gP8odBp yTgZhYcfrDF8pMsp4tc1dkrYi6tVsdUssopV8uQJD9Nt5MsZ5NfQ7wrFLbNdYW3d/mud Q7zG0J816QqzGb24e1P38WrhB6VdPg35xNUbqIsBQH4eXQT8pHowQ84ahPNRpa1Kwx8G cep5saRJ5VPGtpY2l3jWUmGXDoBsK+g8pEsW50gmCKBdF0TXfWtQGrJQOsvZWcrTXpaY tYKyztp4R3KFwSaO0BzF9Rbiho2ip9tdgtNIDldjYdw4DWtlb0F2W+8meQ2cTR33vgdq Vs6g== 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 i6si4118369otj.24.2020.01.30.12.51.08; Thu, 30 Jan 2020 12:51:20 -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 S1727725AbgA3UuN (ORCPT + 99 others); Thu, 30 Jan 2020 15:50:13 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:43564 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727089AbgA3UuN (ORCPT ); Thu, 30 Jan 2020 15:50:13 -0500 Received: by mail-oi1-f193.google.com with SMTP id p125so5005654oif.10 for ; Thu, 30 Jan 2020 12:50:12 -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=Z08RuybXoEe11iM07MN6xxLwPZjJpKeFz19KOn5eV6I=; b=musdL956l+CiGUH2vRsps4EGEPAfb32bciHotBEVhgWfTDf2PeminbXsWWTkNxeLW3 jfyj2hmhGmwL8kuZmyPuUedr867ixK5xWjLz1AAapbc/Hcy0XhBT5d241U7wnpTmoVuQ vevgx/VDB6ncSDggy7LZUsMJpcGcNo9K4gG9E3hBWc1H7k9FAnD1J9WObs/7TC0ox+6x Bt3d94fyYCqWsE9uyJKR8NxglnrMcglJU+kFrz/s59pA+onHYgWwHyCoTgv5HpGMjdcr dfp+Rp7O/4m/mkyrMNRozsy8uR1DNFgADDDFFIpT8bfsreafcVE4d0pYJi8dQ7QNAulV Q+yg== X-Gm-Message-State: APjAAAWuQjPhNVYWMLsayzT6KIuRML1Bul6Gwd5V+DbGUQLsPbyopk7S mUk+oLr/cgbFjJJTyxdFzFFqd0Heag0ArjokstyLxQ== X-Received: by 2002:aca:d6c8:: with SMTP id n191mr4314332oig.103.1580417412327; Thu, 30 Jan 2020 12:50:12 -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: Thu, 30 Jan 2020 21:50:00 +0100 Message-ID: Subject: Re: [PATCH 1/2] Documentation: clarify limitations of hibernation To: Luigi Semenzato Cc: "Rafael J. Wysocki" , Michal Hocko , Linux Memory Management List , linux-kernel , 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 6:21 PM Luigi Semenzato wrote: > > On Mon, Jan 27, 2020 at 8:28 AM Rafael J. Wysocki wrote: > > > > 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. > > OK---I had this wrong, thanks. > > > > 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. > > Yes, that's obvious. > > > 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). > > This all makes sense, but we do this: > > -- add resume=/dev/sdc to the command line > -- attach a disk (/dev/sdc) with size equal to RAM > -- mkswap /dev/sdc > -- swapon /dev/sdc > -- echo disk > /sys/power/state > > and the last operation fails with ENOMEM. Are we doing something > wrong? Are we hitting some other mm bug? I would expect this to work, so the fact that it doesn't work for you indicates a bug somewhere or at least an assumption that doesn't hold. Can you please remind me what you do to trigger the unexpected behavior?