--- mm/page_alloc.c.orig	Fri May 12 20:13:08 2000
+++ mm/page_alloc.c	Mon May 15 11:00:17 2000
@@ -216,6 +216,7 @@
 struct page * __alloc_pages(zonelist_t *zonelist, unsigned long order)
 {
 	zone_t **zone = zonelist->zones;
+	static atomic_t free_before_allocate = ATOMIC_INIT(0);
 	extern wait_queue_head_t kswapd_wait;
 
 	/*
@@ -243,6 +244,9 @@
 			if (page)
 				return page;
 		}
+		/* Somebody else is freeing pages? */
+		if (atomic_read(&free_before_allocate))
+			try_to_free_pages(zonelist->gfp_mask);
 	}
 
 	/*
@@ -270,10 +274,12 @@
 	 */
 	if (!(current->flags & PF_MEMALLOC)) {
 		int gfp_mask = zonelist->gfp_mask;
+		atomic_inc(&free_before_allocate);
 		if (!try_to_free_pages(gfp_mask)) {
 			if (!(gfp_mask & __GFP_HIGH))
 				goto fail;
 		}
+		atomic_dec(&free_before_allocate);
 	}
 
 	/*