Skip to content

Commit aab1728

Browse files
committed
PM / hibernate: Fix user space driven resume regression
Recent commit 8fd37a4 (PM / hibernate: Create memory bitmaps after freezing user space) broke the resume part of the user space driven hibernation (s2disk), because I forgot that the resume utility loaded the image into memory without freezing user space (it still freezes tasks after loading the image). This means that during user space driven resume we need to create the memory bitmaps at the "device open" time rather than at the "freeze tasks" time, so make that happen (that's a special case anyway, so it needs to be treated in a special way). Reported-and-tested-by: Ronald <ronald645@gmail.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 15c03dd commit aab1728

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎kernel/power/snapshot.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,10 @@ int create_basic_memory_bitmaps(void)
743743
struct memory_bitmap *bm1, *bm2;
744744
int error = 0;
745745

746-
BUG_ON(forbidden_pages_map || free_pages_map);
746+
if (forbidden_pages_map && free_pages_map)
747+
return 0;
748+
else
749+
BUG_ON(forbidden_pages_map || free_pages_map);
747750

748751
bm1 = kzalloc(sizeof(struct memory_bitmap), GFP_KERNEL);
749752
if (!bm1)

‎kernel/power/user.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static struct snapshot_data {
3939
char frozen;
4040
char ready;
4141
char platform_support;
42+
bool free_bitmaps;
4243
} snapshot_state;
4344

4445
atomic_t snapshot_device_available = ATOMIC_INIT(1);
@@ -82,6 +83,10 @@ static int snapshot_open(struct inode *inode, struct file *filp)
8283
data->swap = -1;
8384
data->mode = O_WRONLY;
8485
error = pm_notifier_call_chain(PM_RESTORE_PREPARE);
86+
if (!error) {
87+
error = create_basic_memory_bitmaps();
88+
data->free_bitmaps = !error;
89+
}
8590
if (error)
8691
pm_notifier_call_chain(PM_POST_RESTORE);
8792
}
@@ -111,6 +116,8 @@ static int snapshot_release(struct inode *inode, struct file *filp)
111116
pm_restore_gfp_mask();
112117
free_basic_memory_bitmaps();
113118
thaw_processes();
119+
} else if (data->free_bitmaps) {
120+
free_basic_memory_bitmaps();
114121
}
115122
pm_notifier_call_chain(data->mode == O_RDONLY ?
116123
PM_POST_HIBERNATION : PM_POST_RESTORE);
@@ -231,6 +238,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
231238
break;
232239
pm_restore_gfp_mask();
233240
free_basic_memory_bitmaps();
241+
data->free_bitmaps = false;
234242
thaw_processes();
235243
data->frozen = 0;
236244
break;

0 commit comments

Comments
 (0)