[ 22/23] [Suspend2] Modify swsusp to thaw kernel threads while eating memory.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Modify swsusp so that while trying to eat memory, it allows kernel threads
to run. This avoids a deadlock that could otherwise occur if access to a
filesystem is needed while freeing the memory.

Signed-off-by: Nigel Cunningham <[email protected]>

 kernel/power/main.c   |    4 ++++
 kernel/power/swsusp.c |    3 +++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/kernel/power/main.c b/kernel/power/main.c
index 6f854e4..2fed3dc 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -72,6 +72,8 @@ static int suspend_prepare(suspend_state
 		goto Thaw;
 	}
 
+	thaw_processes(FREEZER_KERNEL_THREADS);
+
 	if ((free_pages = nr_free_pages()) < FREE_PAGE_NUMBER) {
 		pr_debug("PM: free some memory\n");
 		shrink_all_memory(FREE_PAGE_NUMBER - free_pages);
@@ -82,6 +84,8 @@ static int suspend_prepare(suspend_state
 		}
 	}
 
+	freeze_processes();
+
 	if (pm_ops->prepare) {
 		if ((error = pm_ops->prepare(state)))
 			goto Thaw;
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 55a18d2..3bc835a 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -575,6 +575,8 @@ int swsusp_shrink_memory(void)
 	unsigned int i = 0;
 	char *p = "-\\|/";
 
+	thaw_processes(FREEZER_KERNEL_THREADS);
+
 	printk("Shrinking memory...  ");
 	do {
 		size = 2 * count_highmem_pages();
@@ -598,6 +600,7 @@ int swsusp_shrink_memory(void)
 	} while (tmp > 0);
 	printk("\bdone (%lu pages freed)\n", pages);
 
+	freeze_processes();
 	return 0;
 }
 

--
Nigel Cunningham		nigel at suspend2 dot net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux