Skip to content

Commit bdbc98a

Browse files
Rainer Fiebigrafaeljw
authored andcommitted
PM: hibernate: Do not subtract NR_FILE_MAPPED in minimum_image_size()
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. 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. Link: https://bugzilla.kernel.org/show_bug.cgi?id=97201 Signed-off-by: Rainer Fiebig <jrf@mailbox.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 30a7acd commit bdbc98a

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎kernel/power/snapshot.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,8 +1645,7 @@ static unsigned long free_unnecessary_pages(void)
16451645
* [number of saveable pages] - [number of pages that can be freed in theory]
16461646
*
16471647
* where the second term is the sum of (1) reclaimable slab pages, (2) active
1648-
* and (3) inactive anonymous pages, (4) active and (5) inactive file pages,
1649-
* minus mapped file pages.
1648+
* and (3) inactive anonymous pages, (4) active and (5) inactive file pages.
16501649
*/
16511650
static unsigned long minimum_image_size(unsigned long saveable)
16521651
{
@@ -1656,8 +1655,7 @@ static unsigned long minimum_image_size(unsigned long saveable)
16561655
+ global_node_page_state(NR_ACTIVE_ANON)
16571656
+ global_node_page_state(NR_INACTIVE_ANON)
16581657
+ global_node_page_state(NR_ACTIVE_FILE)
1659-
+ global_node_page_state(NR_INACTIVE_FILE)
1660-
- global_node_page_state(NR_FILE_MAPPED);
1658+
+ global_node_page_state(NR_INACTIVE_FILE);
16611659

16621660
return saveable <= size ? 0 : saveable - size;
16631661
}

0 commit comments

Comments
 (0)