Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp1227183rdb; Wed, 16 Aug 2023 05:47:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGeZNX8nmX48+EhwMnrF3LYMjQ/+I+B6M/196KOmdjjcvLCsjXot4h96p0WuRr/FQoCHbI/ X-Received: by 2002:a05:6a00:1821:b0:63a:ea82:b7b7 with SMTP id y33-20020a056a00182100b0063aea82b7b7mr2386413pfa.28.1692190050114; Wed, 16 Aug 2023 05:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692190050; cv=none; d=google.com; s=arc-20160816; b=Cus/q4YiTtXbdSS64brb81m5RKvz+P/j0SFHGilEJZQseMIPGEFx+a2gPCGiNc1eLE HSMNWJNPNpmFYw/tSWUERlqz9mRSWugwpbrfWZAyGPjXvZcb+w3zblahTBj/TjJnuKhs LSvVl5o9HX5dLQK3W7MhEuD/KZrQt5t3yKLIPpd3YZUi7bddeEcJJgx8DtKCtnae2MOk zja5PKduEeebhWnnwhf3nDYndRd2QqcdrdLIofnwLTwKWQ1dX6csGTUxayDVMBgGujy0 qsJgCDv9hTWlouSVCCgGpxt2oPMxA8EXszbb4um+j6tduoI98YBtbd4JirMkZRxKQ+WN OiJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:subject:user-agent:mime-version:date:message-id; bh=pGR0T4maOkDqt1InfL0d8KANOXi4MhZ2fw8wxjmVOSw=; fh=QY9hvdtq6NpNM89nZ2F8psb0zbq0hQuRap6/ACF/H1g=; b=fcqrJtMQRKt15zWj0dWxhkZLBgo/TkZlDdUs8+Xby2MiAGWdLX/hPz19pzfF4m8wPB AhHdY0U3Fwqiv+ng3D0xOA0B1bhgxmSidWo21/7CDdRsfUWfYSqlhdQtgdEokxOrYjee qwarVKKqY92tWyQXAirLncwenNg/iMKvRXFDbOjmzMVcyN2sy8Cs2xLMxa9Y41qrYfqo XaneYMU+BCIBD/R6gwHZWf29MmBbQ06z829nf21SVLc6Ox1CMWJLosHO+0b1XVGPrusq Jzwhq5MLKUV/PJXrPVDr1djWrjvwPo+3T9phVPz/UHjv1hqScKzcFS8x5cSHHVhZRgGQ 0kkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q5-20020a056a00150500b006826c5b86dasi11759322pfu.364.2023.08.16.05.47.15; Wed, 16 Aug 2023 05:47:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235686AbjHOIjA (ORCPT + 99 others); Tue, 15 Aug 2023 04:39:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235768AbjHOIir (ORCPT ); Tue, 15 Aug 2023 04:38:47 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9717F133 for ; Tue, 15 Aug 2023 01:38:45 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VprJQL7_1692088721; Received: from 30.97.48.59(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VprJQL7_1692088721) by smtp.aliyun-inc.com; Tue, 15 Aug 2023 16:38:42 +0800 Message-ID: Date: Tue, 15 Aug 2023 16:38:43 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH 4/9] mm/compaction: simplify pfn iteration in isolate_freepages_range To: Kemeng Shi , linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, mgorman@techsingularity.net, david@redhat.com References: <20230805110711.2975149-1-shikemeng@huaweicloud.com> <20230805110711.2975149-5-shikemeng@huaweicloud.com> From: Baolin Wang In-Reply-To: <20230805110711.2975149-5-shikemeng@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/5/2023 7:07 PM, Kemeng Shi wrote: > We call isolate_freepages_block in strict mode, continuous pages in > pageblock will be isolated if isolate_freepages_block successed. > Then pfn + isolated will point to start of next pageblock to scan > no matter how many pageblocks are isolated in isolate_freepages_block. > Use pfn + isolated as start of next pageblock to scan to simplify the > iteration. IIUC, the isolate_freepages_block() can isolate high-order free pages, which means the pfn + isolated can be larger than the block_end_pfn. So in your patch, the 'block_start_pfn' and 'block_end_pfn' can be in different pageblocks, that will break pageblock_pfn_to_page(). > > Signed-off-by: Kemeng Shi > --- > mm/compaction.c | 14 ++------------ > 1 file changed, 2 insertions(+), 12 deletions(-) > > diff --git a/mm/compaction.c b/mm/compaction.c > index 684f6e6cd8bc..8d7d38073d30 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -733,21 +733,11 @@ isolate_freepages_range(struct compact_control *cc, > block_end_pfn = pageblock_end_pfn(pfn); > > for (; pfn < end_pfn; pfn += isolated, > - block_start_pfn = block_end_pfn, > - block_end_pfn += pageblock_nr_pages) { > + block_start_pfn = pfn, > + block_end_pfn = pfn + pageblock_nr_pages) { > /* Protect pfn from changing by isolate_freepages_block */ > unsigned long isolate_start_pfn = pfn; > > - /* > - * pfn could pass the block_end_pfn if isolated freepage > - * is more than pageblock order. In this case, we adjust > - * scanning range to right one. > - */ > - if (pfn >= block_end_pfn) { > - block_start_pfn = pageblock_start_pfn(pfn); > - block_end_pfn = pageblock_end_pfn(pfn); > - } > - > block_end_pfn = min(block_end_pfn, end_pfn); > > if (!pageblock_pfn_to_page(block_start_pfn,