[PATCH v2] PM/hibernation: set the default image size for large memory
From: Xueqin Luo
Date: Thu Mar 02 2023 - 21:48:06 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.
This is the test data for 5 hours after the computer is turned on:
Original kernel begin:
[2023-02-24 19:16:56] [ 46.105423][ 2] [ T3075] PM: hibernation entry
[2023-02-24 19:18:05] [ 56.987043][ 2] [ T3075] PM: hibernation exit
5 hours later:
[2023-02-25 00:22:48] [18069.651640][ 4] [ T7590] PM: hibernation entry
[2023-02-25 00:24:06] [18080.639889][ 2] [ T7590] PM: hibernation exit
After 5h, you can see that the S4 takes 8s more time.
The modified kernel begin:
[2023-02-24 10:47:04] [ 166.309041][ 7] [ T6943] PM: hibernation entry
[2023-02-24 10:48:14] [ 180.382188][ 3] [ T6943] PM: hibernation exit
5 hours later:
[2023-02-24 15:52:08] [18190.171183][ 7] [T11151] PM: hibernation entry
[2023-02-24 15:53:15] [18201.028488][ 2] [T11151] PM: hibernation exit
You can see that after 5 hours, the time doesn't change much.
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