- If max_scan evaluates to zero due to a very small inactive list and high
  `priority' numbers, we don't want to thrlttle yet.

- In balance_pgdat(), we may end up not scanning any pages because all
  zones happened to be above pages_high.  Avoid throttling in this case too.



---

 mm/vmscan.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff -puN mm/vmscan.c~vmscan-dont-throttle-if-zero-max_scan mm/vmscan.c
--- 25/mm/vmscan.c~vmscan-dont-throttle-if-zero-max_scan	2004-02-28 23:38:15.000000000 -0800
+++ 25-akpm/mm/vmscan.c	2004-02-28 23:38:15.000000000 -0800
@@ -872,7 +872,8 @@ int try_to_free_pages(struct zone **zone
 		wakeup_bdflush(total_scanned);
 
 		/* Take a nap, wait for some writeback to complete */
-		blk_congestion_wait(WRITE, HZ/10);
+		if (total_scanned)
+			blk_congestion_wait(WRITE, HZ/10);
 	}
 	if ((gfp_mask & __GFP_FS) && !(gfp_mask & __GFP_NORETRY))
 		out_of_memory();
@@ -917,6 +918,7 @@ static int balance_pgdat(pg_data_t *pgda
 
 	for (priority = DEF_PRIORITY; priority; priority--) {
 		int all_zones_ok = 1;
+		int pages_scanned = 0;
 
 		for (i = 0; i < pgdat->nr_zones; i++) {
 			struct zone *zone = pgdat->node_zones + i;
@@ -935,6 +937,7 @@ static int balance_pgdat(pg_data_t *pgda
 			max_scan = zone->nr_inactive >> priority;
 			reclaimed = shrink_zone(zone, max_scan, GFP_KERNEL,
 					&total_scanned, ps);
+			total_scanned += pages_scanned;
 			reclaim_state->reclaimed_slab = 0;
 			shrink_slab(total_scanned, GFP_KERNEL);
 			reclaimed += reclaim_state->reclaimed_slab;
@@ -952,7 +955,8 @@ static int balance_pgdat(pg_data_t *pgda
 		 * OK, kswapd is getting into trouble.  Take a nap, then take
 		 * another pass across the zones.
 		 */
-		blk_congestion_wait(WRITE, HZ/10);
+		if (pages_scanned)
+			blk_congestion_wait(WRITE, HZ/10);
 	}
 
 	for (i = 0; i < pgdat->nr_zones; i++) {

_