diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2007-05-06 17:50:43 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-07 15:12:59 -0400 |
commit | 74dfd666de861c97d47bdbd892f6d21b801d0247 (patch) | |
tree | 7200946212cf546f4e5fac31db3dc97dbb144300 /kernel/power/disk.c | |
parent | 7be9823491ecbaf9700d7d3502cb4b4dd0ed868a (diff) |
swsusp: do not use page flags
Make swsusp use memory bitmaps instead of page flags for marking 'nosave' and
free pages. This allows us to 'recycle' two page flags that can be used for
other purposes. Also, the memory needed to store the bitmaps is allocated
when necessary (ie. before the suspend) and freed after the resume which is
more reasonable.
The patch is designed to minimize the amount of changes and there are some
nice simplifications and optimizations possible on top of it. I am going to
implement them separately in the future.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/power/disk.c')
-rw-r--r-- | kernel/power/disk.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/kernel/power/disk.c b/kernel/power/disk.c index 8df51c23bba4..403bc3722fee 100644 --- a/kernel/power/disk.c +++ b/kernel/power/disk.c | |||
@@ -139,14 +139,19 @@ int pm_suspend_disk(void) | |||
139 | mdelay(5000); | 139 | mdelay(5000); |
140 | goto Thaw; | 140 | goto Thaw; |
141 | } | 141 | } |
142 | /* Allocate memory management structures */ | ||
143 | error = create_basic_memory_bitmaps(); | ||
144 | if (error) | ||
145 | goto Thaw; | ||
146 | |||
142 | /* Free memory before shutting down devices. */ | 147 | /* Free memory before shutting down devices. */ |
143 | error = swsusp_shrink_memory(); | 148 | error = swsusp_shrink_memory(); |
144 | if (error) | 149 | if (error) |
145 | goto Thaw; | 150 | goto Finish; |
146 | 151 | ||
147 | error = platform_prepare(); | 152 | error = platform_prepare(); |
148 | if (error) | 153 | if (error) |
149 | goto Thaw; | 154 | goto Finish; |
150 | 155 | ||
151 | suspend_console(); | 156 | suspend_console(); |
152 | error = device_suspend(PMSG_FREEZE); | 157 | error = device_suspend(PMSG_FREEZE); |
@@ -181,7 +186,7 @@ int pm_suspend_disk(void) | |||
181 | power_down(); | 186 | power_down(); |
182 | else { | 187 | else { |
183 | swsusp_free(); | 188 | swsusp_free(); |
184 | goto Thaw; | 189 | goto Finish; |
185 | } | 190 | } |
186 | } else { | 191 | } else { |
187 | pr_debug("PM: Image restored successfully.\n"); | 192 | pr_debug("PM: Image restored successfully.\n"); |
@@ -194,6 +199,8 @@ int pm_suspend_disk(void) | |||
194 | platform_finish(); | 199 | platform_finish(); |
195 | device_resume(); | 200 | device_resume(); |
196 | resume_console(); | 201 | resume_console(); |
202 | Finish: | ||
203 | free_basic_memory_bitmaps(); | ||
197 | Thaw: | 204 | Thaw: |
198 | unprepare_processes(); | 205 | unprepare_processes(); |
199 | return error; | 206 | return error; |
@@ -239,13 +246,15 @@ static int software_resume(void) | |||
239 | } | 246 | } |
240 | 247 | ||
241 | pr_debug("PM: Checking swsusp image.\n"); | 248 | pr_debug("PM: Checking swsusp image.\n"); |
242 | |||
243 | error = swsusp_check(); | 249 | error = swsusp_check(); |
244 | if (error) | 250 | if (error) |
245 | goto Done; | 251 | goto Unlock; |
246 | 252 | ||
247 | pr_debug("PM: Preparing processes for restore.\n"); | 253 | error = create_basic_memory_bitmaps(); |
254 | if (error) | ||
255 | goto Unlock; | ||
248 | 256 | ||
257 | pr_debug("PM: Preparing processes for restore.\n"); | ||
249 | error = prepare_processes(); | 258 | error = prepare_processes(); |
250 | if (error) { | 259 | if (error) { |
251 | swsusp_close(); | 260 | swsusp_close(); |
@@ -280,7 +289,9 @@ static int software_resume(void) | |||
280 | printk(KERN_ERR "PM: Restore failed, recovering.\n"); | 289 | printk(KERN_ERR "PM: Restore failed, recovering.\n"); |
281 | unprepare_processes(); | 290 | unprepare_processes(); |
282 | Done: | 291 | Done: |
292 | free_basic_memory_bitmaps(); | ||
283 | /* For success case, the suspend path will release the lock */ | 293 | /* For success case, the suspend path will release the lock */ |
294 | Unlock: | ||
284 | mutex_unlock(&pm_mutex); | 295 | mutex_unlock(&pm_mutex); |
285 | pr_debug("PM: Resume from disk failed.\n"); | 296 | pr_debug("PM: Resume from disk failed.\n"); |
286 | return 0; | 297 | return 0; |