From: Bojan Smojver <bojan@rexursive.com>
To: Per Olofsson <pelle@debian.org>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
linux-kernel@vger.kernel.org,
Linux PM list <linux-pm@vger.kernel.org>
Subject: Re: [PATCH v11]: Hibernation: fix the number of pages used for hibernate/thaw buffering
Date: Mon, 23 Apr 2012 08:29:52 +1000 [thread overview]
Message-ID: <1335133792.2187.8.camel@shrek.rexursive.com> (raw)
In-Reply-To: <4F946B86.4000509@debian.org>
On Sun, 2012-04-22 at 22:35 +0200, Per Olofsson wrote:
> It is also possible to create a much smaller patch which only
> subtracts the high pages and nothing else.
For instance:
---------------------------------------
Hibernation regression fix, since 3.2:
Calculate the number of required free pages based on non-high memory
pages only, because that is where the buffers will come from.
Signed-off-by: Bojan Smojver <bojan@rexursive.com>
---
kernel/power/swap.c | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 8742fd0..fdf834f 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -51,6 +51,23 @@
#define MAP_PAGE_ENTRIES (PAGE_SIZE / sizeof(sector_t) - 1)
+/*
+ * Number of free pages that are not high.
+ */
+static inline unsigned long low_free_pages(void)
+{
+ return nr_free_pages() - nr_free_highpages();
+}
+
+/*
+ * Number of pages required to be kept free while writing the image. Always
+ * half of all available low pages before the writing starts.
+ */
+static inline unsigned long reqd_free_pages(void)
+{
+ return low_free_pages() / 2;
+}
+
struct swap_map_page {
sector_t entries[MAP_PAGE_ENTRIES];
sector_t next_swap;
@@ -72,7 +89,7 @@ struct swap_map_handle {
sector_t cur_swap;
sector_t first_sector;
unsigned int k;
- unsigned long nr_free_pages, written;
+ unsigned long reqd_free_pages;
u32 crc32;
};
@@ -316,8 +333,7 @@ static int get_swap_writer(struct swap_map_handle *handle)
goto err_rel;
}
handle->k = 0;
- handle->nr_free_pages = nr_free_pages() >> 1;
- handle->written = 0;
+ handle->reqd_free_pages = reqd_free_pages();
handle->first_sector = handle->cur_swap;
return 0;
err_rel:
@@ -352,11 +368,11 @@ static int swap_write_page(struct swap_map_handle *handle, void *buf,
handle->cur_swap = offset;
handle->k = 0;
}
- if (bio_chain && ++handle->written > handle->nr_free_pages) {
+ if (bio_chain && low_free_pages() <= handle->reqd_free_pages) {
error = hib_wait_on_bio_chain(bio_chain);
if (error)
goto out;
- handle->written = 0;
+ handle->reqd_free_pages = reqd_free_pages();
}
out:
return error;
@@ -618,7 +634,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
* Adjust number of free pages after all allocations have been done.
* We don't want to run out of pages when writing.
*/
- handle->nr_free_pages = nr_free_pages() >> 1;
+ handle->reqd_free_pages = reqd_free_pages();
/*
* Start the CRC32 thread.
---------------------------------------
--
Bojan
next prev parent reply other threads:[~2012-04-22 22:29 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-12 21:59 [PATCH v11]: Hibernation: fix the number of pages used for hibernate/thaw buffering Bojan Smojver
2012-04-15 12:47 ` Per Olofsson
2012-04-15 22:08 ` Rafael J. Wysocki
2012-04-15 22:31 ` Bojan Smojver
2012-04-16 18:38 ` Rafael J. Wysocki
2012-04-16 19:47 ` Per Olofsson
2012-04-18 21:17 ` Bojan Smojver
2012-04-18 21:30 ` Rafael J. Wysocki
2012-04-18 22:14 ` Bojan Smojver
2012-04-21 22:55 ` Bojan Smojver
2012-04-22 11:47 ` Rafael J. Wysocki
2012-04-22 11:51 ` Per Olofsson
2012-04-22 12:03 ` Rafael J. Wysocki
2012-04-22 12:17 ` Bojan Smojver
2012-04-22 20:29 ` Rafael J. Wysocki
2012-04-22 20:35 ` Per Olofsson
2012-04-22 20:50 ` Rafael J. Wysocki
2012-04-22 22:29 ` Bojan Smojver [this message]
2012-04-23 21:31 ` Bojan Smojver
2012-04-23 21:59 ` Rafael J. Wysocki
2012-04-23 22:04 ` Rafael J. Wysocki
2012-04-23 22:40 ` Bojan Smojver
2012-04-24 22:12 ` Rafael J. Wysocki
2012-04-25 0:55 ` Bojan Smojver
2012-04-26 3:28 ` Bojan Smojver
2012-04-26 20:00 ` Rafael J. Wysocki
2012-04-26 21:13 ` Bojan Smojver
2012-04-26 22:11 ` Rafael J. Wysocki
2012-04-26 22:22 ` Bojan Smojver
2012-04-27 0:16 ` Bojan Smojver
2012-04-27 0:26 ` Bojan Smojver
2012-04-29 21:08 ` Rafael J. Wysocki
2012-04-30 1:43 ` Bojan Smojver
2012-04-29 21:07 ` Rafael J. Wysocki
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=1335133792.2187.8.camel@shrek.rexursive.com \
--to=bojan@rexursive.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@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;
as well as URLs for NNTP newsgroup(s).