diff mbox series

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

Message ID 20230302060033.15661-1-luoxueqin@kylinos.cn (mailing list archive)
State Superseded, archived
Headers show
Series PM/hibernation: set the default image size for large memory | expand

Commit Message

xueqin Luo March 2, 2023, 6 a.m. UTC
From: xueqin Luo <luoxueqin@kylinos.cn>

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@kylinos.cn>
---
 kernel/power/snapshot.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

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;
 }
 
 /*