diff -urN wt9-p2/mm/filemap.c wt9-p3/mm/filemap.c --- wt9-p2/mm/filemap.c Thu Mar 6 19:10:39 2003 +++ wt9-p3/mm/filemap.c Thu Mar 6 19:15:20 2003 @@ -80,6 +80,9 @@ next->pprev_hash = &page->next_hash; if (page->buffers) PAGE_BUG(page); +#ifdef CONFIG_SOFTWARE_SUSPEND + last_suspend_cache_page = page; +#endif inc_nr_cache_pages(page); } diff -urN wt9-p2/mm/page_alloc.c wt9-p3/mm/page_alloc.c --- wt9-p2/mm/page_alloc.c Thu Mar 6 19:10:39 2003 +++ wt9-p3/mm/page_alloc.c Thu Mar 6 19:14:17 2003 @@ -348,6 +348,9 @@ #ifdef CONFIG_SMP per_cpu_pages_t *per_cpu_pages; #endif +#if CONFIG_SOFTWARE_SUSPEND + static unsigned int loopcount; +#endif zone = zonelist->zones; classzone = *zone; @@ -413,8 +416,25 @@ } /* here we're in the low on memory slow path */ - -rebalance: +#if CONFIG_SOFTWARE_SUSPEND + loopcount=0; +#endif +balance: +#ifdef CONFIG_SOFTWARE_SUSPEND + if(gfp_mask & __GFP_FAST) { +/* when using memeat, we ask for all pages that are really free. + 800 calls to reschedule should be sufficient to recall all of them since + when a page can be found, it is after only one reschedule. + Actually I consider this as a bug of alloc_pages, since allocating a + page should not hang in an endless loop when it is clear that no + memory is available (cbd) */ + loopcount++; + //if(!(loopcount%10)) + // printk("_"); + if(loopcount > 800) + return NULL; + } +#endif if (current->flags & (PF_MEMALLOC | PF_MEMDIE) && !in_interrupt()) { zone = zonelist->zones; for (;;) {