[PATCH] PM/hibernation: set the default image size for large memory

From: Xueqin Luo
Date: Thu Mar 02 2023 - 01:02:44 EST


From: xueqin Luo <luoxueqin@xxxxxxxxxx>

We found that the larger the memory, the larger the image saved by the
S4, so that the S4 took longer and longer. However, through observation,
we found that the image size is generally more than 900,000 pages, so
we changed the image_size of a computer with 16GB or more memory to 1
million pages. Let it release more unnecessary pages to reduce S4 run
time.

Signed-off-by: xueqin Luo <luoxueqin@xxxxxxxxxx>
---
kernel/power/snapshot.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index cd8b7b35f1e8..de91d6916359 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -136,7 +136,14 @@ unsigned long image_size;

void __init hibernate_image_size_init(void)
{
- image_size = ((totalram_pages() * 2) / 5) * PAGE_SIZE;
+ /* The totalram pages() for a computer of 16 memory size is
+ * equal to 4032990 pages. And according to our observation,
+ * the average image size is 1000000 pages.
+ */
+ if (totalram_pages() < 4032990)
+ image_size = ((totalram_pages() * 2) / 5) * PAGE_SIZE;
+ else
+ image_size = 1000000 * PAGE_SIZE;
}

/*
--
2.25.1