Commit 5ee04716 authored by Vlastimil Babka's avatar Vlastimil Babka Committed by Linus Torvalds

mm, reclaim: cleanup should_continue_reclaim()

After commit "mm, reclaim: make should_continue_reclaim perform dryrun
detection", closer look at the function shows, that nr_reclaimed == 0
means the function will always return false.  And since non-zero
nr_reclaimed implies non_zero nr_scanned, testing nr_scanned serves no
purpose, and so does the testing for __GFP_RETRY_MAYFAIL.

This patch thus cleans up the function to test only !nr_reclaimed upfront,
and remove the __GFP_RETRY_MAYFAIL test and nr_scanned parameter
completely.  Comment is also updated, explaining that approximating "full
LRU list has been scanned" with nr_scanned == 0 didn't really work.

Link: http://lkml.kernel.org/r/20190806014744.15446-3-mike.kravetz@oracle.comSigned-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
Signed-off-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
Acked-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1c6c1597
...@@ -2586,7 +2586,6 @@ static bool in_reclaim_compaction(struct scan_control *sc) ...@@ -2586,7 +2586,6 @@ static bool in_reclaim_compaction(struct scan_control *sc)
*/ */
static inline bool should_continue_reclaim(struct pglist_data *pgdat, static inline bool should_continue_reclaim(struct pglist_data *pgdat,
unsigned long nr_reclaimed, unsigned long nr_reclaimed,
unsigned long nr_scanned,
struct scan_control *sc) struct scan_control *sc)
{ {
unsigned long pages_for_compaction; unsigned long pages_for_compaction;
...@@ -2597,28 +2596,18 @@ static inline bool should_continue_reclaim(struct pglist_data *pgdat, ...@@ -2597,28 +2596,18 @@ static inline bool should_continue_reclaim(struct pglist_data *pgdat,
if (!in_reclaim_compaction(sc)) if (!in_reclaim_compaction(sc))
return false; return false;
/* Consider stopping depending on scan and reclaim activity */
if (sc->gfp_mask & __GFP_RETRY_MAYFAIL) {
/* /*
* For __GFP_RETRY_MAYFAIL allocations, stop reclaiming if the * Stop if we failed to reclaim any pages from the last SWAP_CLUSTER_MAX
* full LRU list has been scanned and we are still failing * number of pages that were scanned. This will return to the caller
* to reclaim pages. This full LRU scan is potentially * with the risk reclaim/compaction and the resulting allocation attempt
* expensive but a __GFP_RETRY_MAYFAIL caller really wants to succeed * fails. In the past we have tried harder for __GFP_RETRY_MAYFAIL
*/ * allocations through requiring that the full LRU list has been scanned
if (!nr_reclaimed && !nr_scanned) * first, by assuming that zero delta of sc->nr_scanned means full LRU
return false; * scan, but that approximation was wrong, and there were corner cases
} else { * where always a non-zero amount of pages were scanned.
/*
* For non-__GFP_RETRY_MAYFAIL allocations which can presumably
* fail without consequence, stop if we failed to reclaim
* any pages from the last SWAP_CLUSTER_MAX number of
* pages that were scanned. This will return to the
* caller faster at the risk reclaim/compaction and
* the resulting allocation attempt fails
*/ */
if (!nr_reclaimed) if (!nr_reclaimed)
return false; return false;
}
/* If compaction would go ahead or the allocation would succeed, stop */ /* If compaction would go ahead or the allocation would succeed, stop */
for (z = 0; z <= sc->reclaim_idx; z++) { for (z = 0; z <= sc->reclaim_idx; z++) {
...@@ -2645,11 +2634,7 @@ static inline bool should_continue_reclaim(struct pglist_data *pgdat, ...@@ -2645,11 +2634,7 @@ static inline bool should_continue_reclaim(struct pglist_data *pgdat,
if (get_nr_swap_pages() > 0) if (get_nr_swap_pages() > 0)
inactive_lru_pages += node_page_state(pgdat, NR_INACTIVE_ANON); inactive_lru_pages += node_page_state(pgdat, NR_INACTIVE_ANON);
return inactive_lru_pages > pages_for_compaction && return inactive_lru_pages > pages_for_compaction;
/*
* avoid dryrun with plenty of inactive pages
*/
nr_scanned && nr_reclaimed;
} }
static bool pgdat_memcg_congested(pg_data_t *pgdat, struct mem_cgroup *memcg) static bool pgdat_memcg_congested(pg_data_t *pgdat, struct mem_cgroup *memcg)
...@@ -2794,7 +2779,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) ...@@ -2794,7 +2779,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
wait_iff_congested(BLK_RW_ASYNC, HZ/10); wait_iff_congested(BLK_RW_ASYNC, HZ/10);
} while (should_continue_reclaim(pgdat, sc->nr_reclaimed - nr_reclaimed, } while (should_continue_reclaim(pgdat, sc->nr_reclaimed - nr_reclaimed,
sc->nr_scanned - nr_scanned, sc)); sc));
/* /*
* Kswapd gives up on balancing particular nodes after too * Kswapd gives up on balancing particular nodes after too
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment