On Mon, Oct 15, 2012 at 11:54:13AM +0200, Jiri Slaby wrote:> [...]On 10/12/2012 03:57 PM, Mel Gorman wrote:mm: vmscan: scale number of pages reclaimed by reclaim/compaction only in direct reclaim
Jiri Slaby reported the following:
diff --git a/mm/vmscan.c b/mm/vmscan.cYes, applying this instead of the revert fixes the issue as well.
index 2624edc..2b7edfa 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1763,14 +1763,20 @@ static bool in_reclaim_compaction(struct scan_control *sc)
#ifdef CONFIG_COMPACTION
/*
* If compaction is deferred for sc->order then scale the number of pages
- * reclaimed based on the number of consecutive allocation failures
+ * reclaimed based on the number of consecutive allocation failures. This
+ * scaling only happens for direct reclaim as it is about to attempt
+ * compaction. If compaction fails, future allocations will be deferred
+ * and reclaim avoided. On the other hand, kswapd does not take compaction
+ * deferral into account so if it scaled, it could scan excessively even
+ * though allocations are temporarily not being attempted.
*/
static unsigned long scale_for_compaction(unsigned long pages_for_compaction,
struct lruvec *lruvec, struct scan_control *sc)
{
struct zone *zone = lruvec_zone(lruvec);
- if (zone->compact_order_failed <= sc->order)
+ if (zone->compact_order_failed <= sc->order &&
+ !current_is_kswapd())
pages_for_compaction <<= zone->compact_defer_shift;
return pages_for_compaction;
}