From: TGSP <tgsp002@gmail.com>
To: xiongxin@kylinos.cn
Cc: stable@vger.kernel.org, huanglei <huanglei@kylinos.cn>
Subject: [PATCH -next 2/2] PM: hibernate: add check of preallocate mem for image size pages
Date: Tue, 1 Nov 2022 10:23:42 +0800 [thread overview]
Message-ID: <20221101022342.1345980-3-tgsp002@gmail.com> (raw)
In-Reply-To: <20221101022342.1345980-1-tgsp002@gmail.com>
From: xiongxin <xiongxin@kylinos.cn>
Added a check on the return value of preallocate_image_highmem(). If
memory preallocate is insufficient, S4 cannot be done;
I am playing 4K video on a machine with AMD or other graphics card and
only 8GiB memory, and the kernel is not configured with CONFIG_HIGHMEM.
When doing the S4 test, the analysis found that when the pages get from
minimum_image_size() is large enough, The preallocate_image_memory() and
preallocate_image_highmem() calls failed to obtain enough memory. Add
the judgment that memory preallocate is insufficient;
"pages -= free_unnecessary_pages()" below will let pages to drop a lot,
so I wonder if it makes sense to add a judgment here.
Cc: stable@vger.kernel.org
Signed-off-by: xiongxin <xiongxin@kylinos.cn>
Signed-off-by: huanglei <huanglei@kylinos.cn>
---
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 c20ca5fb9adc..670abf89cf31 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -1738,6 +1738,7 @@ int hibernate_preallocate_memory(void)
struct zone *zone;
unsigned long saveable, size, max_size, count, highmem, pages = 0;
unsigned long alloc, save_highmem, pages_highmem, avail_normal;
+ unsigned long size_highmem;
ktime_t start, stop;
int error;
@@ -1863,7 +1864,13 @@ int hibernate_preallocate_memory(void)
pages_highmem += size;
alloc -= size;
size = preallocate_image_memory(alloc, avail_normal);
- pages_highmem += preallocate_image_highmem(alloc - size);
+ size_highmem += preallocate_image_highmem(alloc - size);
+ if (size_highmem < (alloc - size)) {
+ pr_err("Image allocation is %lu pages short, exit\n",
+ alloc - size - pages_highmem);
+ goto err_out;
+ }
+ pages_highmem += size_highmem;
pages += pages_highmem + size;
}
--
2.25.1
next prev parent reply other threads:[~2022-11-01 2:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20221101022342.1345980-1-tgsp002@gmail.com>
2022-11-01 2:23 ` [PATCH -next 1/2] PM: hibernate: fix spelling mistake for annotation TGSP
2022-11-01 2:23 ` TGSP [this message]
[not found] <20221101022840.1351163-1-tgsp002@gmail.com>
2022-11-01 2:28 ` [PATCH -next 2/2] PM: hibernate: add check of preallocate mem for image size pages TGSP
2022-11-01 21:23 ` kernel test robot
2022-11-03 16:47 ` Rafael J. Wysocki
2022-11-03 16:57 ` Rafael J. Wysocki
2022-11-03 17:11 ` Rafael J. Wysocki
[not found] <20221031124823.719912-1-xiongxin@kylinos.cn>
2022-10-31 12:48 ` xiongxin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221101022342.1345980-3-tgsp002@gmail.com \
--to=tgsp002@gmail.com \
--cc=huanglei@kylinos.cn \
--cc=stable@vger.kernel.org \
--cc=xiongxin@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox