All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luigi Semenzato <semenzato@google.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Michal Hocko <mhocko@kernel.org>,
	Linux Memory Management List <linux-mm@kvack.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Geoff Pike <gpike@google.com>
Subject: Re: [PATCH 1/2] Documentation: clarify limitations of hibernation
Date: Thu, 30 Jan 2020 13:36:15 -0800	[thread overview]
Message-ID: <CAA25o9RSWPX8L3s=r6A+4oSdQyvGfWZ1bhKfGvSo5nN-X58HQA@mail.gmail.com> (raw)
In-Reply-To: <CAJZ5v0i=v_+n1yVdmO7L1FYpe=3WQHM03NQqHNfTCTKG5MVtNQ@mail.gmail.com>

On Thu, Jan 30, 2020 at 1:29 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Thu, Jan 30, 2020 at 10:11 PM Luigi Semenzato <semenzato@google.com> wrote:
> >
> > On Thu, Jan 30, 2020 at 12:50 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
> > >
> > > On Mon, Jan 27, 2020 at 6:21 PM Luigi Semenzato <semenzato@google.com> wrote:
> > > >
> > > > On Mon, Jan 27, 2020 at 8:28 AM Rafael J. Wysocki <rafael@kernel.org> wrote:
> > > > >
> > > > > On Mon, Jan 27, 2020 at 5:13 PM Luigi Semenzato <semenzato@google.com> wrote:
> > > > > >
> > > > > > On Mon, Jan 27, 2020 at 6:16 AM Michal Hocko <mhocko@kernel.org> 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?
> >
> > Yes, I create processes that use a large amount of anon memory, more
> > than 50% of RAM, like this:
> >
> > dd if=/dev/zero bs=1G count=1 | sleep infinity
> >
> > I think dd has a 2 GB limit, or around that number, so you'll need a
> > few of those.
>
> And then you get -ENOMEM from hibernate_preallocate_memory(), or from
> somewhere else?

That is correct.  More precisely, preallocate_image_memory() doesn't
get enough pages, and then preallocate_image_highmem() either gets
nothing, or in any case too little.

  reply	other threads:[~2020-01-30 21:36 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-26 22:02 [PATCH 0/2] clarify limitations of hibernation Luigi Semenzato
2019-12-26 22:02 ` Luigi Semenzato
2019-12-26 22:02 ` [PATCH 1/2] Documentation: " Luigi Semenzato
2019-12-26 22:02   ` Luigi Semenzato
2020-01-06 12:53   ` Michal Hocko
2020-01-06 19:08     ` Luigi Semenzato
2020-01-06 19:08       ` Luigi Semenzato
2020-01-08 11:49       ` Michal Hocko
2020-01-24 16:37         ` Luigi Semenzato
2020-01-24 16:37           ` Luigi Semenzato
2020-01-27 14:16           ` Michal Hocko
2020-01-27 16:13             ` Luigi Semenzato
2020-01-27 16:13               ` Luigi Semenzato
2020-01-27 16:28               ` Rafael J. Wysocki
2020-01-27 16:28                 ` Rafael J. Wysocki
2020-01-27 17:21                 ` Luigi Semenzato
2020-01-27 17:21                   ` Luigi Semenzato
2020-01-30 20:50                   ` Rafael J. Wysocki
2020-01-30 20:50                     ` Rafael J. Wysocki
2020-01-30 21:10                     ` Luigi Semenzato
2020-01-30 21:10                       ` Luigi Semenzato
2020-01-30 21:29                       ` Rafael J. Wysocki
2020-01-30 21:29                         ` Rafael J. Wysocki
2020-01-30 21:36                         ` Luigi Semenzato [this message]
2020-01-30 21:36                           ` Luigi Semenzato
2020-01-27 16:14             ` Rafael J. Wysocki
2020-01-27 16:14               ` Rafael J. Wysocki
2020-01-07 10:04     ` Rafael J. Wysocki
2020-01-07 10:04       ` Rafael J. Wysocki
2019-12-26 22:02 ` [PATCH 2/2] pm: add more logging on hibernation failure Luigi Semenzato
2019-12-26 22:02   ` Luigi Semenzato
2019-12-27 21:34 [PATCH 0/2] clarify limitations of hibernation Luigi Semenzato
2019-12-27 21:34 ` [PATCH 1/2] Documentation: " Luigi Semenzato
2019-12-28  0:23   ` Chris Down
2019-12-28  0:25   ` Chris Down
2020-01-02 19:29     ` Luigi Semenzato

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAA25o9RSWPX8L3s=r6A+4oSdQyvGfWZ1bhKfGvSo5nN-X58HQA@mail.gmail.com' \
    --to=semenzato@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=gpike@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.