From: Rainer Fiebig <jrf@mailbox.org>
To: linux-pm@vger.kernel.org
Cc: Thorsten Leemhuis <thl@ct.de>
Subject: [patch]: do not subtract NR_FILE_MAPPED in minimum_image_size()
Date: Fri, 22 Dec 2017 11:13:59 +0100 [thread overview]
Message-ID: <8acc18d9-ba18-21f6-ea33-d47a6596586c@mailbox.org> (raw)
Hi!
s2disk/s2both may fail unnecessarily and erratically if NR_FILE_MAPPED
is high - for instance when using VMs with VirtualBox and perhaps VMware
Player. In those situations s2disk becomes unreliable and therefore
unusable.
A typical scenario is: user issues a s2disk and it fails. User issues a
second s2disk immediately after that and it succeeds. And user wonders why.
The problem is caused by minimum_image_size() in snapshot.c. The value
it returns is roughly 100 % too high because NR_FILE_MAPPED is
subtracted in its calculation which is imo wrong. Eventually the number
of preallocated image pages is falsely too low.
This doesn't matter as long as NR_FILE_MAPPED-values are in a normal
range or in 32bit-environments as the code allows for allocation of
additional pages from highmem.
But with the high values generated by VirtualBox-VMs (a 2-GB-VM causes
NR_FILE_MAPPED go up by 2 GB) it may lead to failure in 64bit-systems.
Not subtracting NR_FILE_MAPPED in minimum_image_size() solves the problem.
I've done at least hundreds of successful s2both/s2disk now on an x86_64
system (with and without VirtualBox) which gives me some confidence that
this is right. It has turned s2disk/s2both from unusable into 100% reliable.
As I don't have 32bit-equipment, I could not test it in such
environment, though.
The problem has also been discussed in a bug-thread which I closed
myself because it obviously led to nowhere
(https://bugzilla.kernel.org/show_bug.cgi?id=97201).
Thoughts?
Rainer Fiebig
___
--- /kernel/power/snapshot.c
+++ /kernel/power/snapshot.c
@@ -1641,8 +1641,7 @@
* [number of saveable pages] - [number of pages that can be freed in
theory]
*
* where the second term is the sum of (1) reclaimable slab pages, (2)
active
- * and (3) inactive anonymous pages, (4) active and (5) inactive file
pages,
- * minus mapped file pages.
+ * and (3) inactive anonymous pages, (4) active and (5) inactive file
pages.
*/
static unsigned long minimum_image_size(unsigned long saveable)
{
@@ -1652,8 +1651,7 @@
+ global_node_page_state(NR_ACTIVE_ANON)
+ global_node_page_state(NR_INACTIVE_ANON)
+ global_node_page_state(NR_ACTIVE_FILE)
- + global_node_page_state(NR_INACTIVE_FILE)
- - global_node_page_state(NR_FILE_MAPPED);
+ + global_node_page_state(NR_INACTIVE_FILE);
return saveable <= size ? 0 : saveable - size;
}
next reply other threads:[~2017-12-22 10:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-22 10:13 Rainer Fiebig [this message]
2018-01-05 13:50 ` [patch]: do not subtract NR_FILE_MAPPED in minimum_image_size() Rafael J. Wysocki
2018-01-05 17:26 ` Rainer Fiebig
2018-01-07 23:41 ` Rafael J. Wysocki
2018-02-16 16:57 ` Rainer Fiebig
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=8acc18d9-ba18-21f6-ea33-d47a6596586c@mailbox.org \
--to=jrf@mailbox.org \
--cc=linux-pm@vger.kernel.org \
--cc=thl@ct.de \
/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.