From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71FF8C4742C for ; Mon, 2 Nov 2020 13:07:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2973D206F1 for ; Mon, 2 Nov 2020 13:07:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728852AbgKBNHQ (ORCPT ); Mon, 2 Nov 2020 08:07:16 -0500 Received: from mx2.suse.de ([195.135.220.15]:54462 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728359AbgKBNHQ (ORCPT ); Mon, 2 Nov 2020 08:07:16 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4E233B810; Mon, 2 Nov 2020 13:07:14 +0000 (UTC) Subject: Re: [PATCH v3 2/2] mm/compaction: stop isolation if too many pages are isolated and we have pages to migrate. To: Zi Yan , Andrew Morton , linux-mm@kvack.org Cc: Yang Shi , Michal Hocko , Rik van Riel , linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20201030183809.3616803-1-zi.yan@sent.com> <20201030183809.3616803-2-zi.yan@sent.com> From: Vlastimil Babka Message-ID: Date: Mon, 2 Nov 2020 14:07:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201030183809.3616803-2-zi.yan@sent.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/30/20 7:38 PM, Zi Yan wrote: > From: Zi Yan > > In isolate_migratepages_block, if we have too many isolated pages and > nr_migratepages is not zero, we should try to migrate what we have > without wasting time on isolating. As you CC stable, there should be a stronger reason (strictly speaking the problem should have been observed in practice, but this is a simple patch, so they could accept it), so I suggest Andrew adds the following paragraph: In theory it's possible that multiple parallel compactions will cause too_many_isolated() to become true even if each has isolated less than COMPACT_CLUSTER_MAX, and loop forever in the while loop. Bailing immediately prevents that. > Fixes: 1da2f328fa64 (“mm,thp,compaction,cma: allow THP migration for CMA allocations”) > Suggested-by: Vlastimil Babka > Signed-off-by: Zi Yan > Cc: Acked-by: Vlastimil Babka > --- > mm/compaction.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/mm/compaction.c b/mm/compaction.c > index 3e834ac402f1..4d237a7c3830 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -817,6 +817,10 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, > * delay for some time until fewer pages are isolated > */ > while (unlikely(too_many_isolated(pgdat))) { > + /* stop isolation if there are still pages not migrated */ > + if (cc->nr_migratepages) > + return 0; > + > /* async migration should just abort */ > if (cc->mode == MIGRATE_ASYNC) > return 0; >