diff -ruNp 2020-kmod-freeze.patch-old/kernel/kmod.c 2020-kmod-freeze.patch-new/kernel/kmod.c
--- 2020-kmod-freeze.patch-old/kernel/kmod.c	2006-02-18 08:56:06.000000000 +1000
+++ 2020-kmod-freeze.patch-new/kernel/kmod.c	2006-02-23 21:36:19.000000000 +1000
@@ -36,6 +36,7 @@
 #include <linux/mount.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/freezer.h>
 #include <asm/uaccess.h>
 
 extern int max_threads;
@@ -249,6 +250,9 @@ int call_usermodehelper_keys(char *path,
 	if (!khelper_wq)
 		return -EBUSY;
 
+	if (freezer_is_on())
+		return 0;
+
 	if (path[0] == '\0')
 		return 0;
 



diff -ruNp 3110-reset-kswapd-max-order-after-resume.patch-old/mm/vmscan.c 3110-reset-kswapd-max-order-after-resume.patch-new/mm/vmscan.c
--- 3110-reset-kswapd-max-order-after-resume.patch-old/mm/vmscan.c	2006-02-14 20:35:24.000000000 +1000
+++ 3110-reset-kswapd-max-order-after-resume.patch-new/mm/vmscan.c	2006-02-15 21:32:53.000000000 +1000
@@ -1724,7 +1724,8 @@ static int kswapd(void *p)
 	for ( ; ; ) {
 		unsigned long new_order;
 
-		try_to_freeze();
+		if (try_to_freeze())
+			pgdat->kswapd_max_order = 0;
 
 		prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
 		new_order = pgdat->kswapd_max_order;






diff -ruNp 9900-Suspend2.patch-old/kernel/power/process.c 9900-Suspend2.patch-new/kernel/power/process.c
--- 9900-Suspend2.patch-old/kernel/power/process.c	2006-06-23 09:24:08.000000000 +1000
+++ 9900-Suspend2.patch-new/kernel/power/process.c	2006-06-22 12:20:12.000000000 +1000
@@ -222,6 +222,8 @@ void thaw_processes(int all)
 	if (!test_freezer_state(FREEZING_COMPLETE))
 		pass++;
 
+	clear_freezer_state(FREEZING_COMPLETE);
+
 	freezer_message( "Restarting tasks..." );
 	read_lock(&tasklist_lock);
 	do {
@@ -248,7 +250,6 @@ void thaw_processes(int all)
 
 	if (all)
 		clear_freezer_state(FREEZER_ON);
-	clear_freezer_state(FREEZING_COMPLETE);
 }
 
 EXPORT_SYMBOL(refrigerator);






diff -ruNp 9930-lkml-pdflush-fix.patch-old/mm/pdflush.c 9930-lkml-pdflush-fix.patch-new/mm/pdflush.c
--- 9930-lkml-pdflush-fix.patch-old/mm/pdflush.c	2006-06-22 12:11:50.000000000 +1000
+++ 9930-lkml-pdflush-fix.patch-new/mm/pdflush.c	2006-06-22 12:20:12.000000000 +1000
@@ -104,12 +104,8 @@ static int __pdflush(struct pdflush_work
 		list_move(&my_work->list, &pdflush_list);
 		my_work->when_i_went_to_sleep = jiffies;
 		spin_unlock_irq(&pdflush_lock);
-
 		schedule();
-		if (try_to_freeze()) {
-			spin_lock_irq(&pdflush_lock);
-			continue;
-		}
+		try_to_freeze();
 
 		spin_lock_irq(&pdflush_lock);
 		if (!list_empty(&my_work->list)) {
@@ -118,7 +114,7 @@ static int __pdflush(struct pdflush_work
 			continue;
 		}
 		if (my_work->fn == NULL) {
-			printk("pdflush: NULL work function\n");
+			printk("pdflush: resuming\n");
 			continue;
 		}
 		spin_unlock_irq(&pdflush_lock);







diff -ruNp 9900-Suspend2.patch-old/mm/page_alloc.c 9900-Suspend2.patch-new/mm/page_alloc.c
--- 9900-Suspend2.patch-old/mm/page_alloc.c	2006-06-22 12:11:50.000000000 +1000
+++ 9900-Suspend2.patch-new/mm/page_alloc.c	2006-06-22 12:35:18.000000000 +1000
@@ -25,6 +25,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/suspend.h>
+#include <linux/freezer.h>
 #include <linux/pagevec.h>
 #include <linux/blkdev.h>
 #include <linux/slab.h>
@@ -905,7 +907,8 @@ get_page_from_freelist(gfp_t gfp_mask, u
 			else
 				mark = (*z)->pages_high;
 			if (!zone_watermark_ok(*z, order, mark,
-				    classzone_idx, alloc_flags))
+				    classzone_idx, alloc_flags) &&
+			    likely(!test_freezer_state(FREEZER_ON)))
 				if (!zone_reclaim_mode ||
 				    !zone_reclaim(*z, gfp_mask, order))
 					continue;
@@ -950,10 +953,12 @@ restart:
 	if (page)
 		goto got_pg;
 
-	do {
-		if (cpuset_zone_allowed(*z, gfp_mask|__GFP_HARDWALL))
-			wakeup_kswapd(*z, order);
-	} while (*(++z));
+	if (likely(!test_freezer_state(FREEZER_ON))) {
+		do {
+			if (cpuset_zone_allowed(*z, gfp_mask|__GFP_HARDWALL))
+				wakeup_kswapd(*z, order);
+		} while (*(++z));
+	}
 
 	/*
 	 * OK, we're below the kswapd watermark and have kicked background
@@ -997,6 +1002,7 @@ nofail_alloc:
 			if (page)
 				goto got_pg;
 			if (gfp_mask & __GFP_NOFAIL) {
+				BUG_ON(unlikely(test_freezer_state(FREEZING_COMPLETE)));
 				blk_congestion_wait(WRITE, HZ/50);
 				goto nofail_alloc;
 			}
@@ -1009,6 +1015,8 @@ nofail_alloc:
 		goto nopage;
 
 rebalance:
+	BUG_ON(unlikely(test_freezer_state(FREEZER_ON)));
+
 	cond_resched();
 
 	/* We now go into synchronous reclaim */








diff -ruNp 9900-Suspend2.patch-old/kernel/timer.c 9900-Suspend2.patch-new/kernel/timer.c
--- 9900-Suspend2.patch-old/kernel/timer.c	2006-06-22 12:11:49.000000000 +1000
+++ 9900-Suspend2.patch-new/kernel/timer.c	2006-06-22 12:20:12.000000000 +1000
@@ -34,6 +34,7 @@
 #include <linux/cpu.h>
 #include <linux/syscalls.h>
 #include <linux/delay.h>
+#include <linux/freezer.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -869,6 +870,16 @@ static inline void calc_load(unsigned lo
 	count -= ticks;
 	if (count < 0) {
 		count += LOAD_FREQ;
+
+		/* Suspend2 does a lot of work (pagecache I/O) before
+		 * and after the atomic copy. If we let the load average
+		 * be updated while suspending, it will be very high post
+		 * resume. Processes such as some MTAs that stop work
+		 * while the average is high will be unnecessarily disrupted.
+		 */
+		if (freezer_is_on())
+			return;
+
 		active_tasks = count_active_tasks();
 		CALC_LOAD(avenrun[0], EXP_1, active_tasks);
 		CALC_LOAD(avenrun[1], EXP_5, active_tasks);

