diff options
-rw-r--r-- | mm/vmscan.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c index 99b434b674c..f6fdae7a8d4 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -1729,6 +1729,28 @@ static bool in_reclaim_compaction(struct scan_control *sc) | |||
1729 | return false; | 1729 | return false; |
1730 | } | 1730 | } |
1731 | 1731 | ||
1732 | #ifdef CONFIG_COMPACTION | ||
1733 | /* | ||
1734 | * If compaction is deferred for sc->order then scale the number of pages | ||
1735 | * reclaimed based on the number of consecutive allocation failures | ||
1736 | */ | ||
1737 | static unsigned long scale_for_compaction(unsigned long pages_for_compaction, | ||
1738 | struct lruvec *lruvec, struct scan_control *sc) | ||
1739 | { | ||
1740 | struct zone *zone = lruvec_zone(lruvec); | ||
1741 | |||
1742 | if (zone->compact_order_failed <= sc->order) | ||
1743 | pages_for_compaction <<= zone->compact_defer_shift; | ||
1744 | return pages_for_compaction; | ||
1745 | } | ||
1746 | #else | ||
1747 | static unsigned long scale_for_compaction(unsigned long pages_for_compaction, | ||
1748 | struct lruvec *lruvec, struct scan_control *sc) | ||
1749 | { | ||
1750 | return pages_for_compaction; | ||
1751 | } | ||
1752 | #endif | ||
1753 | |||
1732 | /* | 1754 | /* |
1733 | * Reclaim/compaction is used for high-order allocation requests. It reclaims | 1755 | * Reclaim/compaction is used for high-order allocation requests. It reclaims |
1734 | * order-0 pages before compacting the zone. should_continue_reclaim() returns | 1756 | * order-0 pages before compacting the zone. should_continue_reclaim() returns |
@@ -1776,6 +1798,9 @@ static inline bool should_continue_reclaim(struct lruvec *lruvec, | |||
1776 | * inactive lists are large enough, continue reclaiming | 1798 | * inactive lists are large enough, continue reclaiming |
1777 | */ | 1799 | */ |
1778 | pages_for_compaction = (2UL << sc->order); | 1800 | pages_for_compaction = (2UL << sc->order); |
1801 | |||
1802 | pages_for_compaction = scale_for_compaction(pages_for_compaction, | ||
1803 | lruvec, sc); | ||
1779 | inactive_lru_pages = get_lru_size(lruvec, LRU_INACTIVE_FILE); | 1804 | inactive_lru_pages = get_lru_size(lruvec, LRU_INACTIVE_FILE); |
1780 | if (nr_swap_pages > 0) | 1805 | if (nr_swap_pages > 0) |
1781 | inactive_lru_pages += get_lru_size(lruvec, LRU_INACTIVE_ANON); | 1806 | inactive_lru_pages += get_lru_size(lruvec, LRU_INACTIVE_ANON); |