Index: linux-2.6.16-rc2/mm/vmscan.c =================================================================== --- linux-2.6.16-rc2.orig/mm/vmscan.c 2006-02-04 21:39:02.000000000 -0800 +++ linux-2.6.16-rc2/mm/vmscan.c 2006-02-04 21:47:20.000000000 -0800 @@ -51,11 +51,6 @@ typedef enum { PAGE_CLEAN, } pageout_t; -struct scan_control { - /* Incremented by the number of inactive pages that were scanned */ - unsigned long nr_scanned; -}; - /* * Some additional flags to be added to gfp_t in the context * of swap processing. @@ -64,16 +59,6 @@ struct scan_control { #define MAY_WRITEPAGE (1 << (__GFP_BITS_SHIFT + 1)) /* - * init_scan_control prepares scan control with the proper settings - * - * nr_pages is the minimum number of pages we intend to free in the scan. - */ -static inline void init_scan_control(struct scan_control *sc) -{ - sc->nr_scanned = 0; -} - -/* * The list of shrinker callbacks used by to apply pressure to * ageable caches. */ @@ -409,12 +394,13 @@ cannot_free: * shrink_list adds the number of reclaimed pages to sc->nr_reclaimed */ static int shrink_list(struct list_head *page_list, gfp_t gfp_mask, - struct scan_control *sc) + unsigned long *total_scanned) { LIST_HEAD(ret_pages); struct pagevec freed_pvec; int pgactivate = 0; int reclaimed = 0; + int nr_scanned = 0; cond_resched(); @@ -435,10 +421,10 @@ static int shrink_list(struct list_head BUG_ON(PageActive(page)); - sc->nr_scanned++; + nr_scanned++; /* Double the slab pressure for mapped and swapcache pages */ if (page_mapped(page) || PageSwapCache(page)) - sc->nr_scanned++; + nr_scanned++; if (PageWriteback(page)) goto keep_locked; @@ -568,6 +554,7 @@ keep: if (pagevec_count(&freed_pvec)) __pagevec_release_nonlru(&freed_pvec); mod_page_state(pgactivate, pgactivate); + *total_scanned += nr_scanned; return reclaimed; } @@ -1077,7 +1064,7 @@ static int isolate_lru_pages(int nr_to_s * shrink_cache() adds the number of pages reclaimed to sc->nr_reclaimed */ static int shrink_cache(int max_scan, struct zone *zone, gfp_t gfp_mask, - int swap_cluster_max, struct scan_control *sc) + int swap_cluster_max, unsigned long *nr_scanned) { LIST_HEAD(page_list); struct pagevec pvec; @@ -1104,7 +1091,7 @@ static int shrink_cache(int max_scan, st goto done; max_scan -= nr_scan; - nr_reclaimed += nr_freed = shrink_list(&page_list, gfp_mask, sc); + nr_reclaimed += nr_freed = shrink_list(&page_list, gfp_mask, nr_scanned); local_irq_disable(); if (current_is_kswapd()) { @@ -1290,7 +1277,7 @@ refill_inactive_zone(int nr_pages, struc */ static int shrink_zone(int priority, struct zone *zone, gfp_t gfp_mask, - unsigned long swap_cluster_max, struct scan_control *sc) + unsigned long swap_cluster_max, unsigned long *nr_scanned) { unsigned long nr_active; unsigned long nr_inactive; @@ -1328,7 +1315,7 @@ shrink_zone(int priority, struct zone *z nr_to_scan = min(nr_inactive, swap_cluster_max); nr_inactive -= nr_to_scan; nr_reclaimed += shrink_cache(nr_to_scan, zone, gfp_mask, - swap_cluster_max, sc); + swap_cluster_max, nr_scanned); } } @@ -1356,7 +1343,7 @@ shrink_zone(int priority, struct zone *z */ static int shrink_caches(int priority, struct zone **zones, gfp_t gfp_mask, - int swap_cluster_max, struct scan_control *sc) + int swap_cluster_max, unsigned long *nr_scanned) { int i; int nr_reclaimed = 0; @@ -1378,7 +1365,7 @@ shrink_caches(int priority, struct zone continue; /* Let kswapd poll it */ nr_reclaimed += shrink_zone(priority, zone, gfp_mask, - swap_cluster_max, sc); + swap_cluster_max, nr_scanned); } return nr_reclaimed; } @@ -1422,20 +1409,18 @@ int try_to_free_pages(struct zone **zone } for (priority = DEF_PRIORITY; priority >= 0; priority--) { - struct scan_control sc; - - init_scan_control(&sc); + unsigned long nr_scanned = 0; if (!priority) disable_swap_token(); total_reclaimed += shrink_caches(priority, zones, gfp_mask, - SWAP_CLUSTER_MAX, &sc); - shrink_slab(sc.nr_scanned, gfp_mask, lru_pages); + SWAP_CLUSTER_MAX, &nr_scanned); + shrink_slab(nr_scanned, gfp_mask, lru_pages); if (reclaim_state) { total_reclaimed += reclaim_state->reclaimed_slab; reclaim_state->reclaimed_slab = 0; } - total_scanned += sc.nr_scanned; + total_scanned += nr_scanned; if (total_reclaimed >= SWAP_CLUSTER_MAX) { ret = 1; goto out; @@ -1454,7 +1439,7 @@ int try_to_free_pages(struct zone **zone } /* Take a nap, wait for some writeback to complete */ - if (sc.nr_scanned && priority < DEF_PRIORITY - 2) + if (nr_scanned && priority < DEF_PRIORITY - 2) blk_congestion_wait(WRITE, HZ/10); } out: @@ -1572,7 +1557,7 @@ scan: */ for (i = 0; i <= end_zone; i++) { struct zone *zone = pgdat->node_zones + i; - struct scan_control sc; + unsigned long nr_scanned = 0; int nr_slab; if (!populated_zone(zone)) @@ -1590,17 +1575,15 @@ scan: if (zone->prev_priority > priority) zone->prev_priority = priority; - init_scan_control(&sc); - atomic_inc(&zone->reclaim_in_progress); total_reclaimed += shrink_zone(priority, zone, gfp_mask, - max(nr_pages, SWAP_CLUSTER_MAX), &sc); + max(nr_pages, SWAP_CLUSTER_MAX), &nr_scanned); atomic_dec(&zone->reclaim_in_progress); reclaim_state->reclaimed_slab = 0; - nr_slab = shrink_slab(sc.nr_scanned, GFP_KERNEL, + nr_slab = shrink_slab(nr_scanned, GFP_KERNEL, lru_pages); total_reclaimed += reclaim_state->reclaimed_slab; - total_scanned += sc.nr_scanned; + total_scanned += nr_scanned; if (zone->all_unreclaimable) continue; if (nr_slab == 0 && zone->pages_scanned >= @@ -1846,11 +1829,11 @@ int zone_reclaim(struct zone *zone, gfp_ int nr_pages; struct task_struct *p = current; struct reclaim_state reclaim_state; - struct scan_control sc; cpumask_t mask; int node_id; int priority; int total_reclaimed; + unsigned long nr_scanned; if (time_before(jiffies, zone->last_unsuccessful_zone_reclaim + zone_reclaim_interval)) @@ -1874,7 +1857,7 @@ int zone_reclaim(struct zone *zone, gfp_ disable_swap_token(); nr_pages = 1 << order; - init_scan_control(&sc); + nr_scanned = 0; total_reclaimed = 0; cond_resched(); @@ -1890,7 +1873,7 @@ int zone_reclaim(struct zone *zone, gfp_ priority >=0 && total_reclaimed < nr_pages; priority--) total_reclaimed += shrink_zone(priority, zone, gfp_mask, - max(nr_pages, SWAP_CLUSTER_MAX), &sc); + max(nr_pages, SWAP_CLUSTER_MAX), &nr_scanned); if (total_reclaimed < nr_pages && (zone_reclaim_mode & RECLAIM_SLAB)) { @@ -1902,7 +1885,7 @@ int zone_reclaim(struct zone *zone, gfp_ * shrink_slab will free memory on all zones and may take * a long time. */ - shrink_slab(sc.nr_scanned, gfp_mask, order); + shrink_slab(nr_scanned, gfp_mask, order); total_reclaimed = 1; /* Avoid getting the off node timeout */ }