Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3733751ybl; Mon, 27 Jan 2020 09:22:49 -0800 (PST) X-Google-Smtp-Source: APXvYqxXYRgIaZTXLObIfR9C6MaTw5cYpLdU9joMadllEnosydJgTFGz025VtIBXXiXX3eeEsNoB X-Received: by 2002:aca:c452:: with SMTP id u79mr67792oif.89.1580145769211; Mon, 27 Jan 2020 09:22:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580145769; cv=none; d=google.com; s=arc-20160816; b=Z/UCCLXY4sZ0wXI9VAKePbL9H1igvSAOTLRNUxntk2stvzMisnlJFjEinSyknqEUms U7bbGggTs1s1oSHCbfZJYnm7tpn7GBzSDk9MBsWJq4XXBuAT9NOBrbzobwYqtBXofUdC eK2QNbreSuTXf9s92GtGEcECzsWXROD7/o2+VuQTRxgg+haBNRBKuBzBWZH/6VMWRubk xNlpRzNbUQjSzjDhls4XAKE5JA+9jdh46gN9VgFWXvlrc5smWycg5oEeeTbD62x2yw4z iHI4veeOstUYVuq/S4qltwibQdrsFrR50uwQ5IuvZ2kh3o4jE7Std11Mixt5qV07n9Al jOCA== 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:dkim-signature; bh=FlVv3OiGshIByx4bdZlL96riWYmzI3zF0LMlVGex22I=; b=f1neJwLNCJLxbijwmZstjKtLvhapDOpzMgUUgzxe+nfHEIWyqVt8sUf3zVA3qoK/VI kiyJzWPNYzhcohzWoveWqZ4Cp4Rv6gDnbsBgUS/fugeMZhXt7USVOUqdf55kCNrc+Atb a6ewRaV1iRrDzrb+kM51lSjuM4M88BYw1z9S6hwFPUk5gM9iAa1OGEOmAaYHQppyGuhS FvZehKUoyOXLv2kKvk9ZpR9bKz8JFYGXdBqNdAN6Har+HjJcZPWOce/lDOEx1iQT5SSE pQkMI0Xcn6HMrnkGg93Q8ExGVYDNZ0+TmQMmXTnWeZLMH7eZLLJoq/ArGLC3YOW6p29+ 2Qaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hJnxUJNV; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o7si7221072otk.185.2020.01.27.09.22.36; Mon, 27 Jan 2020 09:22:49 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=hJnxUJNV; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726004AbgA0RVi (ORCPT + 99 others); Mon, 27 Jan 2020 12:21:38 -0500 Received: from mail-il1-f196.google.com ([209.85.166.196]:42109 "EHLO mail-il1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725845AbgA0RVi (ORCPT ); Mon, 27 Jan 2020 12:21:38 -0500 Received: by mail-il1-f196.google.com with SMTP id x2so4428849ila.9 for ; Mon, 27 Jan 2020 09:21:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FlVv3OiGshIByx4bdZlL96riWYmzI3zF0LMlVGex22I=; b=hJnxUJNVX5ujJFbvBapdFCAEPbl+jm/DXbMzBPzjb1o5n3mHiupGbT11C+eTMrk/eb aIaF/wk5AEY5Gy6TQOgc0YHh39SYb3mqFxK9xAEyoCVMJ3tm4yl/OgCF54m7tg379ad8 +EThVtfC4feIY2LUh2aTTCP+tMXfZe4bEpZjbi7zZDTc6S3mk3g00zF2JMnZW0XJIK7I DkV2rFDwhCKCdlX7DKJMgAMifhHjJR6YXNNGI/0vvuF8nc/lFKZu7Eh3uLW0ao+lETWW dNHxipd1PAaPeR1Mb5Zrt+22E9dcyC3udphRNJTQNJ92svPoEjN1g0E9jNCHgusMtRvk xj9w== 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=FlVv3OiGshIByx4bdZlL96riWYmzI3zF0LMlVGex22I=; b=cT/55wnIqEZThhpKiyTKK+TFbHbbtI0Sk0wW+L3ZUH3llA7CCahjNUCyFdT8ujvPL7 v8rLH2qfqieIrWMLQJ1KBpSpBv1iV5fDnmsHZMaA89svydbvTliZa+pyEDNs3K1DaaSz sPVxiKb7BAYC+pmomx1rIxj6FqpdJpW6T16G/sIQzqb8sXmbmwhNgoutDclOBdPDXpSo Ef/un63E2b0uT7zP5my8rDrwO/PEe1hP3hgflQf/IcZw2KPntrPMQfE7S8ABPKS+qmlj zbWcOUKwzlG6mOD4h//lfIvWvS0RXqArsGuga4wwTPdHfTier/dn4NNo6zSLvuA6r/XW vnOw== X-Gm-Message-State: APjAAAW4OJ7yf+0qkKn5iSOSbuAFOWh4Bo7AAcel0flQ0xRmNZI8aXbt 958rb15UwjKXnDYVDfRix5ZIue2uE46EQXG1yrCVyw== X-Received: by 2002:a92:d642:: with SMTP id x2mr15910283ilp.169.1580145697386; Mon, 27 Jan 2020 09:21:37 -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: Luigi Semenzato Date: Mon, 27 Jan 2020 09:21:25 -0800 Message-ID: Subject: Re: [PATCH 1/2] Documentation: clarify limitations of hibernation To: "Rafael J. Wysocki" Cc: 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 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? Thanks!