Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755858AbaFIJFf (ORCPT ); Mon, 9 Jun 2014 05:05:35 -0400 Received: from ip4-83-240-18-248.cust.nbox.cz ([83.240.18.248]:58449 "EHLO ip4-83-240-18-248.cust.nbox.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755059AbaFIIvZ (ORCPT ); Mon, 9 Jun 2014 04:51:25 -0400 From: Jiri Slaby To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Johannes Weiner , Rik van Riel , Andrew Morton , Linus Torvalds , Jiri Slaby Subject: [PATCH 3.12 068/146] revert "mm: vmscan: do not swap anon pages just because free+file is low" Date: Mon, 9 Jun 2014 10:50:03 +0200 Message-Id: <245fd39e32a9e849fab4120e09950bb073b8982e.1402303821.git.jslaby@suse.cz> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Weiner 3.12-stable review patch. If anyone has any objections, please let me know. =============== commit 623762517e2370be3b3f95f4fe08d6c063a49b06 upstream. This reverts commit 0bf1457f0cfc ("mm: vmscan: do not swap anon pages just because free+file is low") because it introduced a regression in mostly-anonymous workloads, where reclaim would become ineffective and trap every allocating task in direct reclaim. The problem is that there is a runaway feedback loop in the scan balance between file and anon, where the balance tips heavily towards a tiny thrashing file LRU and anonymous pages are no longer being looked at. The commit in question removed the safe guard that would detect such situations and respond with forced anonymous reclaim. This commit was part of a series to fix premature swapping in loads with relatively little cache, and while it made a small difference, the cure is obviously worse than the disease. Revert it. Signed-off-by: Johannes Weiner Reported-by: Christian Borntraeger Acked-by: Christian Borntraeger Acked-by: Rafael Aquini Cc: Rik van Riel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Jiri Slaby --- mm/vmscan.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index 05e6095159dc..09c730718e23 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1898,6 +1898,24 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, } /* + * Prevent the reclaimer from falling into the cache trap: as + * cache pages start out inactive, every cache fault will tip + * the scan balance towards the file LRU. And as the file LRU + * shrinks, so does the window for rotation from references. + * This means we have a runaway feedback loop where a tiny + * thrashing file LRU becomes infinitely more attractive than + * anon pages. Try to detect this based on file LRU size. + */ + if (global_reclaim(sc)) { + unsigned long free = zone_page_state(zone, NR_FREE_PAGES); + + if (unlikely(file + free <= high_wmark_pages(zone))) { + scan_balance = SCAN_ANON; + goto out; + } + } + + /* * There is enough inactive page cache, do not reclaim * anything from the anonymous working set right now. */ -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/