Messages in this thread Patch in this message | | | From | Xueqin Luo <> | Subject | [PATCH v2] PM/hibernation: set the default image size for large memory | Date | Fri, 3 Mar 2023 13:51:33 +0800 |
| |
From: xueqin Luo <luoxueqin@kylinos.cn>
As computers have more and more memory, they can store larger and larger images. This poses a problem. Let's take a 16GB computer as an example. When the number of pre-allocated pages is greater than 900,000 and smaller than image_size, the duration of S4 increases with the number of saved pages. When the number of pre-allocated pages reaches 1.2 million, the duration of S4 increases by 8-10s.
We found that the image size is generally more than 900,000 pages, so we set the default size of image_size for 16GB and above computers to 1 million pages, which can reduce the running time of S4 under certain conditions.
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:16:59] [ 47.632000][ 1] [ T3075] done (allocated 959239 pages) [2023-02-24 19:18:05] [ 56.987043][ 2] [ T3075] PM: hibernation exit
Five hours later:
[2023-02-25 00:22:48] [18069.651640][ 4] [ T7590] PM: hibernation entry [2023-02-25 01:23:59] [21671.194049][ 0] [ T8563] done (allocated 1228878 pages) [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.
Five hours later, the modified kernel test data:
[2023-02-24 15:52:08] [18190.171183][ 7] [T11151] PM: hibernation entry [2023-02-24 15:52:11] [18191.677021][ 7] [T11151] done (allocated 792597 pages) [2023-02-24 15:53:15] [18201.028488][ 2] [T11151] PM: hibernation exit
You can see that after five hours, the time has changed little compared to the initial test data.
Signed-off-by: xueqin Luo <luoxueqin@kylinos.cn> ---
v3: modify some comments
v2: add test data
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..fa3950b19849 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 less than 1 million pages. + */ + if (totalram_pages() < 4032990) + image_size = ((totalram_pages() * 2) / 5) * PAGE_SIZE; + else + image_size = 1000000 * PAGE_SIZE; } /* -- 2.25.1
| |