Atomic reclaim: Make cond_resched's conditional We cannot reschedule if we are in atomic reclaim. So make the calls to cond_resched depending on the __GFP_WAIT flag. Signed-off-by: Christoph Lameter --- mm/vmscan.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) Index: linux-2.6/mm/vmscan.c =================================================================== --- linux-2.6.orig/mm/vmscan.c 2007-08-13 21:49:16.000000000 -0700 +++ linux-2.6/mm/vmscan.c 2007-08-13 21:49:45.000000000 -0700 @@ -251,6 +251,15 @@ static int may_write_to_queue(struct bac } /* + * Reschedule if we are not in atomic mode + */ +static void reclaim_resched(struct scan_control *sc) +{ + if (sc->gfp_mask & __GFP_WAIT) + cond_resched(); +} + +/* * We detected a synchronous write error writing a page out. Probably * -ENOSPC. We need to propagate that into the address_space for a subsequent * fsync(), msync() or close(). @@ -430,7 +439,7 @@ static unsigned long shrink_page_list(st int pgactivate = 0; unsigned long nr_reclaimed = 0; - cond_resched(); + reclaim_resched(sc); pagevec_init(&freed_pvec, 1); while (!list_empty(page_list)) { @@ -439,7 +448,7 @@ static unsigned long shrink_page_list(st int may_enter_fs; int referenced; - cond_resched(); + reclaim_resched(sc); page = lru_to_page(page_list); list_del(&page->lru); @@ -931,7 +940,7 @@ force_reclaim_mapped: spin_unlock_irq(&zone->lru_lock); while (!list_empty(&l_hold)) { - cond_resched(); + reclaim_resched(sc); page = lru_to_page(&l_hold); list_del(&page->lru); if (page_mapped(page)) {