PM: hibernate: fix spelling mistake for annotation
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/2 PM: hibernate: fix spelling mistake for annotation
From: xiongxin <[email protected]>
The actual calculation formula in the code below is:
max_size = (count - (size + PAGES_FOR_IO)) / 2
- 2 * DIV_ROUND_UP(reserved_size, PAGE_SIZE);
But function comments are written differently, the comment is wrong?
By the way, what exactly do the "/ 2" and "2 *" mean?
--- kernel/power/snapshot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/power/snapshot.c +2 -2
@@ -1723,8 +1723,8 @@ static unsigned long minimum_image_size(unsigned long saveable)* /sys/power/reserved_size, respectively). To make this happen, we compute the * total number of available page frames and allocate at least * -* ([page frames total] + PAGES_FOR_IO + [metadata pages]) / 2 -* + 2 * DIV_ROUND_UP(reserved_size, PAGE_SIZE) +* ([page frames total] - PAGES_FOR_IO - [metadata pages]) / 2 +* - 2 * DIV_ROUND_UP(reserved_size, PAGE_SIZE) * * of them, which corresponds to the maximum size of a hibernation image. *
Signature · 1 line
2.25.1
PATCH 2/2 PM: hibernate: add check of preallocate mem for image size pages
In reply to a message not in the archiveFrom: xiongxin <[email protected]>
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.
--- kernel/power/snapshot.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
kernel/power/snapshot.c +8 -1
@@ -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; }
Signature · 1 line
2.25.1