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=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 0B80AC433E0 for ; Thu, 28 Jan 2021 13:25:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 531EA61492 for ; Thu, 28 Jan 2021 13:25:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 531EA61492 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5BE126B007E; Thu, 28 Jan 2021 08:25:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 56FA86B0080; Thu, 28 Jan 2021 08:25:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4ADDC6B0081; Thu, 28 Jan 2021 08:25:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0091.hostedemail.com [216.40.44.91]) by kanga.kvack.org (Postfix) with ESMTP id 36E1E6B007E for ; Thu, 28 Jan 2021 08:25:14 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id EC96C180AD837 for ; Thu, 28 Jan 2021 13:25:13 +0000 (UTC) X-FDA: 77755254906.09.bun30_57154f9275a0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id D309E180AD81D for ; Thu, 28 Jan 2021 13:25:13 +0000 (UTC) X-HE-Tag: bun30_57154f9275a0 X-Filterd-Recvd-Size: 4022 Received: from outbound-smtp55.blacknight.com (outbound-smtp55.blacknight.com [46.22.136.239]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Thu, 28 Jan 2021 13:25:12 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail05.blacknight.ie [81.17.254.26]) by outbound-smtp55.blacknight.com (Postfix) with ESMTPS id 90DC6FB6E8 for ; Thu, 28 Jan 2021 13:25:10 +0000 (GMT) Received: (qmail 31758 invoked from network); 28 Jan 2021 13:25:10 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.22.4]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 28 Jan 2021 13:25:10 -0000 Date: Thu, 28 Jan 2021 13:25:08 +0000 From: Mel Gorman To: Wonhyuk Yang Cc: Andrew Morton , Vlastimil Babka , linux-mm@kvack.org Subject: Re: [PATCH v2] mm/compactoin: Fix misbehaviors of fast_find_migrateblock() Message-ID: <20210128132508.GE3592@techsingularity.net> References: <20210128130411.6125-1-vvghjk1234@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20210128130411.6125-1-vvghjk1234@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jan 28, 2021 at 10:04:11PM +0900, Wonhyuk Yang wrote: > In the fast_find_migrateblock(), It iterate freelist to find > proper pageblock. But there are some misbehaviors. > > First, if the page we found is equal to cc->migrate_pfn, it > is considered that we didn't found suitable pageblock. Second, > if the loop was terminated because order is less than > PAGE_ALLOC_COSTLY_ORDER, it could be considered that we found > suitable one. Third, if the skip bit is set on the page block > and go continue, it doesn't check the nr_scanned. Fourth, if > the page block's skip bit is set, it check that page block is > the last of list. But it is unnecessary. > > Fixes: 70b44595eafe9 ("mm, compaction: use free lists to quickly locate > a migration source") > > Signed-off-by: Wonhyuk Yang > --- > Changes in v2: > - Follow Vlastimil's suggestions, using bool varable. > - Fix new misbehavior and remove unecessary . > > v1: https://lore.kernel.org/linux-mm/20210123154320.24278-1-vvghjk1234@gmail.com > --- > mm/compaction.c | 27 ++++++++++++--------------- > 1 file changed, 12 insertions(+), 15 deletions(-) > > diff --git a/mm/compaction.c b/mm/compaction.c > index e5acb9714436..8e5cd9d20435 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -1701,6 +1701,7 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) > unsigned long pfn = cc->migrate_pfn; > unsigned long high_pfn; > int order; > + bool found_block = false; > > /* Skip hints are relied on to avoid repeats on the fast search */ > if (cc->ignore_skip_hint) > @@ -1743,7 +1744,7 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) > high_pfn = pageblock_start_pfn(cc->migrate_pfn + distance); > > for (order = cc->order - 1; > - order >= PAGE_ALLOC_COSTLY_ORDER && pfn == cc->migrate_pfn && nr_scanned < limit; > + order >= PAGE_ALLOC_COSTLY_ORDER && !found_block && nr_scanned < limit; > order--) { > struct free_area *area = &cc->zone->free_area[order]; > struct list_head *freelist; > @@ -1758,7 +1759,11 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) > list_for_each_entry(freepage, freelist, lru) { > unsigned long free_pfn; > > - nr_scanned++; > + if (nr_scanned++ >= limit) { > + move_freelist_tail(freelist, freepage); > + break; > + } > + > free_pfn = page_to_pfn(freepage); > if (free_pfn < high_pfn) { > /* As nr_scanned is post-incremented, this will still consider if the page should be used when the limit is reached. ++nr_scanned? -- Mel Gorman SUSE Labs