]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
c2757b4664c3c71e782df93c5b11f54d1c7c100e
[thirdparty/kernel/stable-queue.git] /
1 From d20bdd571ee5c9966191568527ecdb1bd4b52368 Mon Sep 17 00:00:00 2001
2 From: Zi Yan <ziy@nvidia.com>
3 Date: Fri, 13 Nov 2020 22:51:43 -0800
4 Subject: mm/compaction: stop isolation if too many pages are isolated and we have pages to migrate
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Zi Yan <ziy@nvidia.com>
10
11 commit d20bdd571ee5c9966191568527ecdb1bd4b52368 upstream.
12
13 In isolate_migratepages_block, if we have too many isolated pages and
14 nr_migratepages is not zero, we should try to migrate what we have
15 without wasting time on isolating.
16
17 In theory it's possible that multiple parallel compactions will cause
18 too_many_isolated() to become true even if each has isolated less than
19 COMPACT_CLUSTER_MAX, and loop forever in the while loop. Bailing
20 immediately prevents that.
21
22 [vbabka@suse.cz: changelog addition]
23
24 Fixes: 1da2f328fa64 (“mm,thp,compaction,cma: allow THP migration for CMA allocations”)
25 Suggested-by: Vlastimil Babka <vbabka@suse.cz>
26 Signed-off-by: Zi Yan <ziy@nvidia.com>
27 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
28 Cc: <stable@vger.kernel.org>
29 Cc: Mel Gorman <mgorman@techsingularity.net>
30 Cc: Michal Hocko <mhocko@kernel.org>
31 Cc: Rik van Riel <riel@surriel.com>
32 Cc: Yang Shi <shy828301@gmail.com>
33 Link: https://lkml.kernel.org/r/20201030183809.3616803-2-zi.yan@sent.com
34 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
35 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
36
37 ---
38 mm/compaction.c | 4 ++++
39 1 file changed, 4 insertions(+)
40
41 --- a/mm/compaction.c
42 +++ b/mm/compaction.c
43 @@ -818,6 +818,10 @@ isolate_migratepages_block(struct compac
44 * delay for some time until fewer pages are isolated
45 */
46 while (unlikely(too_many_isolated(pgdat))) {
47 + /* stop isolation if there are still pages not migrated */
48 + if (cc->nr_migratepages)
49 + return 0;
50 +
51 /* async migration should just abort */
52 if (cc->mode == MIGRATE_ASYNC)
53 return 0;