aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRik van Riel <riel@redhat.com>2012-03-21 19:33:51 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-21 20:54:56 -0400
commitfe2c2a106663130a5ab45cb0e3414b52df2fff0c (patch)
tree4c2651ee4e33c73069bc41fa936b5227c9d9f2a9
parent67f96aa252e606cdf6c3cf1032952ec207ec0cf0 (diff)
vmscan: reclaim at order 0 when compaction is enabled
When built with CONFIG_COMPACTION, kswapd should not try to free contiguous pages, because it is not trying hard enough to have a real chance at being successful, but still disrupts the LRU enough to break other things. Do not do higher order page isolation unless we really are in lumpy reclaim mode. Stop reclaiming pages once we have enough free pages that compaction can deal with things, and we hit the normal order 0 watermarks used by kswapd. Also remove a line of code that increments balanced right before exiting the function. Signed-off-by: Rik van Riel <riel@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Acked-by: Mel Gorman <mel@csn.ul.ie> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Minchan Kim <minchan.kim@gmail.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Hillf Danton <dhillf@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/vmscan.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 8dfa59866af2..d7dad2a4e69c 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1138,7 +1138,7 @@ int __isolate_lru_page(struct page *page, isolate_mode_t mode, int file)
1138 * @mz: The mem_cgroup_zone to pull pages from. 1138 * @mz: The mem_cgroup_zone to pull pages from.
1139 * @dst: The temp list to put pages on to. 1139 * @dst: The temp list to put pages on to.
1140 * @nr_scanned: The number of pages that were scanned. 1140 * @nr_scanned: The number of pages that were scanned.
1141 * @order: The caller's attempted allocation order 1141 * @sc: The scan_control struct for this reclaim session
1142 * @mode: One of the LRU isolation modes 1142 * @mode: One of the LRU isolation modes
1143 * @active: True [1] if isolating active pages 1143 * @active: True [1] if isolating active pages
1144 * @file: True [1] if isolating file [!anon] pages 1144 * @file: True [1] if isolating file [!anon] pages
@@ -1147,8 +1147,8 @@ int __isolate_lru_page(struct page *page, isolate_mode_t mode, int file)
1147 */ 1147 */
1148static unsigned long isolate_lru_pages(unsigned long nr_to_scan, 1148static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
1149 struct mem_cgroup_zone *mz, struct list_head *dst, 1149 struct mem_cgroup_zone *mz, struct list_head *dst,
1150 unsigned long *nr_scanned, int order, isolate_mode_t mode, 1150 unsigned long *nr_scanned, struct scan_control *sc,
1151 int active, int file) 1151 isolate_mode_t mode, int active, int file)
1152{ 1152{
1153 struct lruvec *lruvec; 1153 struct lruvec *lruvec;
1154 struct list_head *src; 1154 struct list_head *src;
@@ -1194,7 +1194,7 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
1194 BUG(); 1194 BUG();
1195 } 1195 }
1196 1196
1197 if (!order) 1197 if (!sc->order || !(sc->reclaim_mode & RECLAIM_MODE_LUMPYRECLAIM))
1198 continue; 1198 continue;
1199 1199
1200 /* 1200 /*
@@ -1208,8 +1208,8 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
1208 */ 1208 */
1209 zone_id = page_zone_id(page); 1209 zone_id = page_zone_id(page);
1210 page_pfn = page_to_pfn(page); 1210 page_pfn = page_to_pfn(page);
1211 pfn = page_pfn & ~((1 << order) - 1); 1211 pfn = page_pfn & ~((1 << sc->order) - 1);
1212 end_pfn = pfn + (1 << order); 1212 end_pfn = pfn + (1 << sc->order);
1213 for (; pfn < end_pfn; pfn++) { 1213 for (; pfn < end_pfn; pfn++) {
1214 struct page *cursor_page; 1214 struct page *cursor_page;
1215 1215
@@ -1275,7 +1275,7 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
1275 1275
1276 *nr_scanned = scan; 1276 *nr_scanned = scan;
1277 1277
1278 trace_mm_vmscan_lru_isolate(order, 1278 trace_mm_vmscan_lru_isolate(sc->order,
1279 nr_to_scan, scan, 1279 nr_to_scan, scan,
1280 nr_taken, 1280 nr_taken,
1281 nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, 1281 nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed,
@@ -1533,9 +1533,8 @@ shrink_inactive_list(unsigned long nr_to_scan, struct mem_cgroup_zone *mz,
1533 1533
1534 spin_lock_irq(&zone->lru_lock); 1534 spin_lock_irq(&zone->lru_lock);
1535 1535
1536 nr_taken = isolate_lru_pages(nr_to_scan, mz, &page_list, 1536 nr_taken = isolate_lru_pages(nr_to_scan, mz, &page_list, &nr_scanned,
1537 &nr_scanned, sc->order, 1537 sc, isolate_mode, 0, file);
1538 isolate_mode, 0, file);
1539 if (global_reclaim(sc)) { 1538 if (global_reclaim(sc)) {
1540 zone->pages_scanned += nr_scanned; 1539 zone->pages_scanned += nr_scanned;
1541 if (current_is_kswapd()) 1540 if (current_is_kswapd())
@@ -1711,8 +1710,7 @@ static void shrink_active_list(unsigned long nr_to_scan,
1711 1710
1712 spin_lock_irq(&zone->lru_lock); 1711 spin_lock_irq(&zone->lru_lock);
1713 1712
1714 nr_taken = isolate_lru_pages(nr_to_scan, mz, &l_hold, 1713 nr_taken = isolate_lru_pages(nr_to_scan, mz, &l_hold, &nr_scanned, sc,
1715 &nr_scanned, sc->order,
1716 isolate_mode, 1, file); 1714 isolate_mode, 1, file);
1717 if (global_reclaim(sc)) 1715 if (global_reclaim(sc))
1718 zone->pages_scanned += nr_scanned; 1716 zone->pages_scanned += nr_scanned;
@@ -2758,7 +2756,7 @@ loop_again:
2758 */ 2756 */
2759 for (i = 0; i <= end_zone; i++) { 2757 for (i = 0; i <= end_zone; i++) {
2760 struct zone *zone = pgdat->node_zones + i; 2758 struct zone *zone = pgdat->node_zones + i;
2761 int nr_slab; 2759 int nr_slab, testorder;
2762 unsigned long balance_gap; 2760 unsigned long balance_gap;
2763 2761
2764 if (!populated_zone(zone)) 2762 if (!populated_zone(zone))
@@ -2791,7 +2789,20 @@ loop_again:
2791 (zone->present_pages + 2789 (zone->present_pages +
2792 KSWAPD_ZONE_BALANCE_GAP_RATIO-1) / 2790 KSWAPD_ZONE_BALANCE_GAP_RATIO-1) /
2793 KSWAPD_ZONE_BALANCE_GAP_RATIO); 2791 KSWAPD_ZONE_BALANCE_GAP_RATIO);
2794 if (!zone_watermark_ok_safe(zone, order, 2792 /*
2793 * Kswapd reclaims only single pages with compaction
2794 * enabled. Trying too hard to reclaim until contiguous
2795 * free pages have become available can hurt performance
2796 * by evicting too much useful data from memory.
2797 * Do not reclaim more than needed for compaction.
2798 */
2799 testorder = order;
2800 if (COMPACTION_BUILD && order &&
2801 compaction_suitable(zone, order) !=
2802 COMPACT_SKIPPED)
2803 testorder = 0;
2804
2805 if (!zone_watermark_ok_safe(zone, testorder,
2795 high_wmark_pages(zone) + balance_gap, 2806 high_wmark_pages(zone) + balance_gap,
2796 end_zone, 0)) { 2807 end_zone, 0)) {
2797 shrink_zone(priority, zone, &sc); 2808 shrink_zone(priority, zone, &sc);
@@ -2820,7 +2831,7 @@ loop_again:
2820 continue; 2831 continue;
2821 } 2832 }
2822 2833
2823 if (!zone_watermark_ok_safe(zone, order, 2834 if (!zone_watermark_ok_safe(zone, testorder,
2824 high_wmark_pages(zone), end_zone, 0)) { 2835 high_wmark_pages(zone), end_zone, 0)) {
2825 all_zones_ok = 0; 2836 all_zones_ok = 0;
2826 /* 2837 /*
@@ -2917,6 +2928,10 @@ out:
2917 if (zone->all_unreclaimable && priority != DEF_PRIORITY) 2928 if (zone->all_unreclaimable && priority != DEF_PRIORITY)
2918 continue; 2929 continue;
2919 2930
2931 /* Would compaction fail due to lack of free memory? */
2932 if (compaction_suitable(zone, order) == COMPACT_SKIPPED)
2933 goto loop_again;
2934
2920 /* Confirm the zone is balanced for order-0 */ 2935 /* Confirm the zone is balanced for order-0 */
2921 if (!zone_watermark_ok(zone, 0, 2936 if (!zone_watermark_ok(zone, 0,
2922 high_wmark_pages(zone), 0, 0)) { 2937 high_wmark_pages(zone), 0, 0)) {
@@ -2926,8 +2941,6 @@ out:
2926 2941
2927 /* If balanced, clear the congested flag */ 2942 /* If balanced, clear the congested flag */
2928 zone_clear_flag(zone, ZONE_CONGESTED); 2943 zone_clear_flag(zone, ZONE_CONGESTED);
2929 if (i <= *classzone_idx)
2930 balanced += zone->present_pages;
2931 } 2944 }
2932 } 2945 }
2933 2946