From: Vlastimil Babka <vbabka@suse.cz>
To: Michal Hocko <mhocko@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Mel Gorman <mgorman@techsingularity.net>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
David Rientjes <rientjes@google.com>,
Rik van Riel <riel@redhat.com>, Vlastimil Babka <vbabka@suse.cz>
Subject: [PATCH v2 18/18] mm, vmscan: use proper classzone_idx in should_continue_reclaim()
Date: Tue, 31 May 2016 15:08:18 +0200 [thread overview]
Message-ID: <20160531130818.28724-19-vbabka@suse.cz> (raw)
In-Reply-To: <20160531130818.28724-1-vbabka@suse.cz>
The should_continue_reclaim() function decides during direct reclaim/compaction
whether shrink_zone() should continue reclaming, or whether compaction is ready
to proceed in that zone. This relies mainly on the compaction_suitable() check,
but by passing a zero classzone_idx, there can be false positives and reclaim
terminates prematurely. Fix this by passing proper classzone_idx.
Additionally, the function checks whether (2UL << pages) were reclaimed. This
however overlaps with the same gap used by compaction_suitable(), and since the
number sc->nr_reclaimed is accumulated over all reclaimed zones, it doesn't
make much sense for deciding about a given single zone anyway. So just drop
this code.
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
mm/vmscan.c | 31 +++++++++----------------------
1 file changed, 9 insertions(+), 22 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 640d2e615c36..391e5d2c4e32 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2309,11 +2309,9 @@ static bool in_reclaim_compaction(struct scan_control *sc)
static inline bool should_continue_reclaim(struct zone *zone,
unsigned long nr_reclaimed,
unsigned long nr_scanned,
- struct scan_control *sc)
+ struct scan_control *sc,
+ int classzone_idx)
{
- unsigned long pages_for_compaction;
- unsigned long inactive_lru_pages;
-
/* If not in reclaim/compaction mode, stop */
if (!in_reclaim_compaction(sc))
return false;
@@ -2341,20 +2339,8 @@ static inline bool should_continue_reclaim(struct zone *zone,
return false;
}
- /*
- * If we have not reclaimed enough pages for compaction and the
- * inactive lists are large enough, continue reclaiming
- */
- pages_for_compaction = compact_gap(sc->order);
- inactive_lru_pages = zone_page_state(zone, NR_INACTIVE_FILE);
- if (get_nr_swap_pages() > 0)
- inactive_lru_pages += zone_page_state(zone, NR_INACTIVE_ANON);
- if (sc->nr_reclaimed < pages_for_compaction &&
- inactive_lru_pages > pages_for_compaction)
- return true;
-
/* If compaction would go ahead or the allocation would succeed, stop */
- switch (compaction_suitable(zone, sc->order, 0, 0)) {
+ switch (compaction_suitable(zone, sc->order, 0, classzone_idx)) {
case COMPACT_PARTIAL:
case COMPACT_CONTINUE:
return false;
@@ -2364,11 +2350,12 @@ static inline bool should_continue_reclaim(struct zone *zone,
}
static bool shrink_zone(struct zone *zone, struct scan_control *sc,
- bool is_classzone)
+ int classzone_idx)
{
struct reclaim_state *reclaim_state = current->reclaim_state;
unsigned long nr_reclaimed, nr_scanned;
bool reclaimable = false;
+ bool is_classzone = (classzone_idx == zone_idx(zone));
do {
struct mem_cgroup *root = sc->target_mem_cgroup;
@@ -2450,7 +2437,7 @@ static bool shrink_zone(struct zone *zone, struct scan_control *sc,
reclaimable = true;
} while (should_continue_reclaim(zone, sc->nr_reclaimed - nr_reclaimed,
- sc->nr_scanned - nr_scanned, sc));
+ sc->nr_scanned - nr_scanned, sc, classzone_idx));
return reclaimable;
}
@@ -2580,7 +2567,7 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
/* need some check for avoid more shrink_zone() */
}
- shrink_zone(zone, sc, zone_idx(zone) == classzone_idx);
+ shrink_zone(zone, sc, classzone_idx);
}
/*
@@ -3076,7 +3063,7 @@ static bool kswapd_shrink_zone(struct zone *zone,
balance_gap, classzone_idx))
return true;
- shrink_zone(zone, sc, zone_idx(zone) == classzone_idx);
+ shrink_zone(zone, sc, classzone_idx);
clear_bit(ZONE_WRITEBACK, &zone->flags);
@@ -3678,7 +3665,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
* priorities until we have enough memory freed.
*/
do {
- shrink_zone(zone, &sc, true);
+ shrink_zone(zone, &sc, zone_idx(zone));
} while (sc.nr_reclaimed < nr_pages && --sc.priority >= 0);
}
--
2.8.3
next prev parent reply other threads:[~2016-05-31 13:09 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-31 13:08 [PATCH v2 00/18] make direct compaction more deterministic Vlastimil Babka
2016-05-31 13:08 ` [PATCH v2 01/18] mm, compaction: don't isolate PageWriteback pages in MIGRATE_SYNC_LIGHT mode Vlastimil Babka
2016-05-31 13:08 ` [PATCH v2 02/18] mm, page_alloc: set alloc_flags only once in slowpath Vlastimil Babka
2016-05-31 13:08 ` [PATCH v2 03/18] mm, page_alloc: don't retry initial attempt " Vlastimil Babka
2016-06-01 13:26 ` Michal Hocko
2016-06-01 14:58 ` Vlastimil Babka
2016-05-31 13:08 ` [PATCH v2 04/18] mm, page_alloc: restructure direct compaction handling " Vlastimil Babka
2016-05-31 13:08 ` [PATCH v2 05/18] mm, page_alloc: make THP-specific decisions more generic Vlastimil Babka
2016-05-31 13:08 ` [PATCH v2 06/18] mm, thp: remove __GFP_NORETRY from khugepaged and madvised allocations Vlastimil Babka
2016-06-01 13:33 ` Michal Hocko
2016-05-31 13:08 ` [PATCH v2 07/18] mm, compaction: introduce direct compaction priority Vlastimil Babka
2016-05-31 13:08 ` [PATCH v2 08/18] mm, compaction: simplify contended compaction handling Vlastimil Babka
2016-05-31 13:08 ` [PATCH v2 09/18] mm, compaction: make whole_zone flag ignore cached scanner positions Vlastimil Babka
2016-05-31 13:08 ` [PATCH v2 10/18] mm, compaction: cleanup unused functions Vlastimil Babka
2016-06-01 13:45 ` Michal Hocko
2016-05-31 13:08 ` [PATCH v2 11/18] mm, compaction: add the ultimate direct compaction priority Vlastimil Babka
2016-05-31 13:08 ` [PATCH v2 12/18] mm, compaction: more reliably increase " Vlastimil Babka
2016-06-01 13:51 ` Michal Hocko
2016-06-23 14:41 ` Vlastimil Babka
2016-05-31 13:08 ` [PATCH v2 13/18] mm, compaction: use correct watermark when checking allocation success Vlastimil Babka
2016-06-01 13:59 ` Michal Hocko
2016-05-31 13:08 ` [PATCH v2 14/18] mm, compaction: create compact_gap wrapper Vlastimil Babka
2016-06-01 14:02 ` Michal Hocko
2016-05-31 13:08 ` [PATCH v2 15/18] mm, compaction: use proper alloc_flags in __compaction_suitable() Vlastimil Babka
2016-05-31 13:08 ` [PATCH v2 16/18] mm, compaction: require only min watermarks for non-costly orders Vlastimil Babka
2016-06-01 14:08 ` Michal Hocko
2016-05-31 13:08 ` [PATCH v2 17/18] mm, vmscan: make compaction_ready() more accurate and readable Vlastimil Babka
2016-06-01 14:14 ` Michal Hocko
2016-05-31 13:08 ` Vlastimil Babka [this message]
2016-06-01 14:21 ` [PATCH v2 18/18] mm, vmscan: use proper classzone_idx in should_continue_reclaim() Michal Hocko
2016-06-01 15:19 ` Vlastimil Babka
2016-06-01 15:45 ` Michal Hocko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160531130818.28724-19-vbabka@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@kernel.org \
--cc=riel@redhat.com \
--cc=rientjes@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).