diff options
author | Wu Fengguang <fengguang.wu@intel.com> | 2009-06-16 18:32:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-16 22:47:39 -0400 |
commit | 6e08a369ee10b361ac1cdcdf4fabd420fd08beb3 (patch) | |
tree | 9dbf870cad025b64781d9051b6680a8a23927e5a /mm/vmscan.c | |
parent | 56e49d218890f49b0057710a4b6fef31f5ffbfec (diff) |
vmscan: cleanup the scan batching code
The vmscan batching logic is twisting. Move it into a standalone function
nr_scan_try_batch() and document it. No behavior change.
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Acked-by: Rik van Riel <riel@redhat.com>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Christoph Lameter <cl@linux-foundation.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/vmscan.c')
-rw-r--r-- | mm/vmscan.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c index 9673437a5457..d4da097533ce 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -1492,6 +1492,26 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc, | |||
1492 | percent[1] = 100 - percent[0]; | 1492 | percent[1] = 100 - percent[0]; |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | /* | ||
1496 | * Smallish @nr_to_scan's are deposited in @nr_saved_scan, | ||
1497 | * until we collected @swap_cluster_max pages to scan. | ||
1498 | */ | ||
1499 | static unsigned long nr_scan_try_batch(unsigned long nr_to_scan, | ||
1500 | unsigned long *nr_saved_scan, | ||
1501 | unsigned long swap_cluster_max) | ||
1502 | { | ||
1503 | unsigned long nr; | ||
1504 | |||
1505 | *nr_saved_scan += nr_to_scan; | ||
1506 | nr = *nr_saved_scan; | ||
1507 | |||
1508 | if (nr >= swap_cluster_max) | ||
1509 | *nr_saved_scan = 0; | ||
1510 | else | ||
1511 | nr = 0; | ||
1512 | |||
1513 | return nr; | ||
1514 | } | ||
1495 | 1515 | ||
1496 | /* | 1516 | /* |
1497 | * This is a basic per-zone page freer. Used by both kswapd and direct reclaim. | 1517 | * This is a basic per-zone page freer. Used by both kswapd and direct reclaim. |
@@ -1517,14 +1537,11 @@ static void shrink_zone(int priority, struct zone *zone, | |||
1517 | scan >>= priority; | 1537 | scan >>= priority; |
1518 | scan = (scan * percent[file]) / 100; | 1538 | scan = (scan * percent[file]) / 100; |
1519 | } | 1539 | } |
1520 | if (scanning_global_lru(sc)) { | 1540 | if (scanning_global_lru(sc)) |
1521 | zone->lru[l].nr_scan += scan; | 1541 | nr[l] = nr_scan_try_batch(scan, |
1522 | nr[l] = zone->lru[l].nr_scan; | 1542 | &zone->lru[l].nr_saved_scan, |
1523 | if (nr[l] >= swap_cluster_max) | 1543 | swap_cluster_max); |
1524 | zone->lru[l].nr_scan = 0; | 1544 | else |
1525 | else | ||
1526 | nr[l] = 0; | ||
1527 | } else | ||
1528 | nr[l] = scan; | 1545 | nr[l] = scan; |
1529 | } | 1546 | } |
1530 | 1547 | ||
@@ -2124,11 +2141,11 @@ static void shrink_all_zones(unsigned long nr_pages, int prio, | |||
2124 | l == LRU_ACTIVE_FILE)) | 2141 | l == LRU_ACTIVE_FILE)) |
2125 | continue; | 2142 | continue; |
2126 | 2143 | ||
2127 | zone->lru[l].nr_scan += (lru_pages >> prio) + 1; | 2144 | zone->lru[l].nr_saved_scan += (lru_pages >> prio) + 1; |
2128 | if (zone->lru[l].nr_scan >= nr_pages || pass > 3) { | 2145 | if (zone->lru[l].nr_saved_scan >= nr_pages || pass > 3) { |
2129 | unsigned long nr_to_scan; | 2146 | unsigned long nr_to_scan; |
2130 | 2147 | ||
2131 | zone->lru[l].nr_scan = 0; | 2148 | zone->lru[l].nr_saved_scan = 0; |
2132 | nr_to_scan = min(nr_pages, lru_pages); | 2149 | nr_to_scan = min(nr_pages, lru_pages); |
2133 | nr_reclaimed += shrink_list(l, nr_to_scan, zone, | 2150 | nr_reclaimed += shrink_list(l, nr_to_scan, zone, |
2134 | sc, prio); | 2151 | sc, prio); |