Skip to contentSkip to conversation

Software Suspend split to two stage.

PATCH New [email protected] 1 participant 1 message Nov 19, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Software Suspend split to two stage.

Hi Pavel Machek:

Here is a workable patch for kernel 2.6.9. It test passed in my computer, please give some comments.

- How it works.
First calculate the PageCache pages count, and then allocate pagedir for it, then calculate the other pages (pageset1 in suspend2) , then allocate it's pagedir.

Second, Write PageCache to swap device.

Final, Snapshot the whole memory, copy pageset1, then save to swap device.

- Why need it.
Not need free PageCache before suspend.

- TODO:
* Using ASYNC to write/read PageCache.

- This idea is from suspend2.

kernel/power/disk.c +11 -8
diff -ur linux-2.6.9/kernel/power/disk.c linux-2.6.9-hg/kernel/power/disk.c
@@ -17,7 +17,6 @@
 #include <linux/fs.h>
 #include "power.h"
 
-
 extern u32 pm_disk_mode;
 extern struct pm_ops * pm_ops;
 
@@ -26,7 +25,7 @@
 extern int swsusp_read(void);
 extern int swsusp_resume(void);
 extern int swsusp_free(void);
-
+extern int pcs_suspend(int resume);
 
 static int noresume = 0;
 char resume_file[256] = CONFIG_PM_STD_PARTITION;
@@ -73,7 +72,7 @@
 
 static int in_suspend __nosavedata = 0;
 
-
+#if 0
 /**
  *	free_some_memory -  Try to free as much memory as possible
  *
@@ -91,7 +90,7 @@
 	printk("|\n");
 }
 
-
+#endif
 static inline void platform_finish(void)
 {
 	if (pm_disk_mode == PM_DISK_PLATFORM) {
@@ -104,13 +103,14 @@
 {
 	device_resume();
 	platform_finish();
+	pcs_suspend(2);
 	enable_nonboot_cpus();
 	thaw_processes();
 	pm_restore_console();
 }
 
 
-static int prepare(void)
+static int prepare(int resume)
 {
 	int error;
 
@@ -130,9 +130,12 @@
 	}
 
 	/* Free memory before shutting down devices. */
-	free_some_memory();
+	//free_some_memory();
 
 	disable_nonboot_cpus();
+	if ((error = pcs_suspend(resume))) {
+		goto Finish;
+	}
 	if ((error = device_suspend(PM_SUSPEND_DISK)))
 		goto Finish;
 
@@ -160,7 +163,7 @@
 {
 	int error;
 
-	if ((error = prepare()))
+	if ((error = prepare(0)))
 		return error;
 
 	pr_debug("PM: Attempting to suspend to disk.\n");
@@ -226,7 +229,7 @@
 
 	pr_debug("PM: Preparing system for restore.\n");
 
-	if ((error = prepare()))
+	if ((error = prepare(1)))
 		goto Free;
 
 	barrier();

#include <linux/smp_lock.h>

kernel/power/swsusp.c +285 -53

415 lines not on this page · raw message

--
Hu Gang / Steve
Linux Registered User 204016
GPG Public Key: http://soulinfo.com/~hugang/hugang.asc