 page_alloc.c |    4 ++--
 vmscan.c     |   29 ++++++++++++++++++++++++++++-
 2 files changed, 30 insertions(+), 3 deletions(-)
diff -ruNp 162-disable-lru-scanning-during-suspend.patch-old/mm/page_alloc.c 162-disable-lru-scanning-during-suspend.patch-new/mm/page_alloc.c
--- 162-disable-lru-scanning-during-suspend.patch-old/mm/page_alloc.c	2005-06-30 15:08:41.000000000 +1000
+++ 162-disable-lru-scanning-during-suspend.patch-new/mm/page_alloc.c	2005-07-17 09:07:13.000000000 +1000
@@ -862,8 +862,8 @@ zone_reclaim_retry:
 
 	/* This allocation should allow future memory freeing. */
 
-	if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE)))
-			&& !in_interrupt()) {
+	if ((((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE))) && !in_interrupt()) ||
+		       (test_suspend_state(SUSPEND_RUNNING)))	{
 		if (!(gfp_mask & __GFP_NOMEMALLOC)) {
 			/* go through the zonelist yet again, ignoring mins */
 			for (i = 0; (z = zones[i]) != NULL; i++) {
diff -ruNp 162-disable-lru-scanning-during-suspend.patch-old/mm/vmscan.c 162-disable-lru-scanning-during-suspend.patch-new/mm/vmscan.c
--- 162-disable-lru-scanning-during-suspend.patch-old/mm/vmscan.c	2005-07-17 09:06:59.000000000 +1000
+++ 162-disable-lru-scanning-during-suspend.patch-new/mm/vmscan.c	2005-07-17 09:07:12.000000000 +1000
@@ -33,6 +33,7 @@
 #include <linux/cpuset.h>
 #include <linux/notifier.h>
 #include <linux/rwsem.h>
+#include <linux/suspend.h>
 
 #include <asm/tlbflush.h>
 #include <asm/div64.h>
@@ -138,6 +139,14 @@ static long total_memory;
 static LIST_HEAD(shrinker_list);
 static DECLARE_RWSEM(shrinker_rwsem);
 
+#ifdef CONFIG_PM
+static atomic_t nr_scanning_lru;
+#define INC_NR_SCANNING_LRU do { atomic_inc(&nr_scanning_lru); } while(0)
+#define DEC_NR_SCANNING_LRU do { atomic_dec(&nr_scanning_lru); } while(0)
+#else
+#define INC_NR_SCANNING_LRU do { } while(0)
+#define DEC_NR_SCANNING_LRU do { } while(0)
+#endif
 /*
  * Add a shrinker callback to be called from the vm
  */
@@ -933,6 +942,8 @@ int try_to_free_pages(struct zone **zone
 	unsigned long lru_pages = 0;
 	int i;
 
+	INC_NR_SCANNING_LRU;
+
 	sc.gfp_mask = gfp_mask;
 	sc.may_writepage = 0;
 	sc.may_swap = 1;
@@ -1004,6 +1015,9 @@ out:
 
 		zone->prev_priority = zone->temp_priority;
 	}
+
+	DEC_NR_SCANNING_LRU;
+
 	return ret;
 }
 
@@ -1176,7 +1190,7 @@ out:
 
 		zone->prev_priority = zone->temp_priority;
 	}
-	if (!all_zones_ok) {
+	if (!all_zones_ok && !nr_pages) {
 		cond_resched();
 		goto loop_again;
 	}
@@ -1277,6 +1291,19 @@ void wakeup_kswapd(struct zone *zone, in
 }
 
 #ifdef CONFIG_PM
+/* freeze_lru
+ *
+ * Put a hold on the pages in the LRU.
+ *
+ * Used by Suspend2, which saves LRU pages separately, and can't have LRU
+ * changing under it.
+ */
+void freeze_lru(void)
+{
+	while (atomic_read(&nr_scanning_lru))
+		schedule();
+}
+
 /*
  * Try to free `nr_pages' of memory, system-wide.  Returns the number of freed
  * pages.

