public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Bojan Smojver <bojan@rexursive.com>
To: Per Olofsson <pelle@debian.org>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v10]: Hibernation: fix the number of pages used for hibernate/thaw buffering
Date: Fri, 13 Apr 2012 07:30:10 +1000	[thread overview]
Message-ID: <1334266210.2573.8.camel@shrek.rexursive.com> (raw)
In-Reply-To: <4F870317.1030408@debian.org>

On Thu, 2012-04-12 at 18:30 +0200, Per Olofsson wrote:
> Indeed. I think what you want is:
> 
> read_pages = min(low_free_pages(),
>                  nr_free_pages() - snapshot_get_image_size()) / 2; 

I was thinking more like this:
----------------------
unsigned long read_pages = 0;

[...]

if (low_free_pages() > snapshot_get_image_size())
       read_pages = (low_free_pages() - snapshot_get_image_size()) / 2;
read_pages = clamp_val(read_pages, LZO_MIN_RD_PAGES, LZO_MAX_RD_PAGES);
----------------------

Where LZO_MIN_RD_PAGES and LZO_MAX_RD_PAGES are set to 1024 and 8192,
respectively (this was picked empirically).

Because we don't really know how many highmem pages are in the image
(this is figured out by prepare_image() function, half way through
reading the image - so way after this calculation is done), we assume
the worst case scenario. And that is that there are no highmem pages in
the image.

Given that we cannot use pages from highmem for buffers anyway, the
above should be careful enough. Of course, there is still some
possibility of running out of pages, but the kernel is usually in a
pretty good shape memory-wise on image load, so we should be able to
squeeze a few MBs out of it, at least.

-- 
Bojan


  reply	other threads:[~2012-04-12 21:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-10 10:08 [PATCH v10]: Hibernation: fix the number of pages used for hibernate/thaw buffering Bojan Smojver
2012-04-12 11:31 ` Bojan Smojver
2012-04-12 16:30   ` Per Olofsson
2012-04-12 21:30     ` Bojan Smojver [this message]
2012-04-15 12:46       ` Per Olofsson

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=1334266210.2573.8.camel@shrek.rexursive.com \
    --to=bojan@rexursive.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pelle@debian.org \
    --cc=rjw@sisk.pl \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox