Skip to content

Commit 042f99c

Browse files
committed
Merge branch 'pm-sleep'
Merge fixes related to system sleep for 7.0-rc6: - Prevent pm_restore_gfp_mask() from triggering a WARN_ON() in some code paths in which it is legitimately called without invoking pm_restrict_gfp_mask() previously (Youngjun Park) - Update snapshot_write_finalize() to take trailing zero pages into account properly which prevents user space restore from failing subsequently in some cases (Alberto Garcia) * pm-sleep: PM: sleep: Drop spurious WARN_ON() from pm_restore_gfp_mask() PM: hibernate: Drain trailing zero pages on userspace restore
2 parents 6a28fb8 + a8d51ef commit 042f99c

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

kernel/power/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void pm_restore_gfp_mask(void)
4040
{
4141
WARN_ON(!mutex_is_locked(&system_transition_mutex));
4242

43-
if (WARN_ON(!saved_gfp_count) || --saved_gfp_count)
43+
if (!saved_gfp_count || --saved_gfp_count)
4444
return;
4545

4646
gfp_allowed_mask = saved_gfp_mask;

kernel/power/snapshot.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,6 +2855,17 @@ int snapshot_write_finalize(struct snapshot_handle *handle)
28552855
{
28562856
int error;
28572857

2858+
/*
2859+
* Call snapshot_write_next() to drain any trailing zero pages,
2860+
* but make sure we're in the data page region first.
2861+
* This function can return PAGE_SIZE if the kernel was expecting
2862+
* another copy page. Return -ENODATA in that situation.
2863+
*/
2864+
if (handle->cur > nr_meta_pages + 1) {
2865+
error = snapshot_write_next(handle);
2866+
if (error)
2867+
return error > 0 ? -ENODATA : error;
2868+
}
28582869
copy_last_highmem_page();
28592870
error = hibernate_restore_protect_page(handle->buffer);
28602871
/* Do that only if we have loaded the image entirely */

0 commit comments

Comments
 (0)