Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9058876rwd; Wed, 21 Jun 2023 02:23:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Ztazc19eFvgIi4Tm+/g6y2LUIx/umP4o1Gfv14KiKPIa/6bOMGAK985srhFibA0OIvF7c X-Received: by 2002:a17:902:dad1:b0:1b1:c6b1:bd99 with SMTP id q17-20020a170902dad100b001b1c6b1bd99mr11676333plx.49.1687339439229; Wed, 21 Jun 2023 02:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687339439; cv=none; d=google.com; s=arc-20160816; b=ITzaq9KQ5IjIT846WlMgcsh1FqgrI0lpn2dOj3PKsJ1KtIe9SLc1svPbcOvl4CtS/v zhpve9zQBE4oP9R/vXrZaV4J9WFJBLg9LPMHH6TOQxCKhbFNdmxOjx6DvrLIjTGra+Dt W5j2bXFqC+VUQSHzBlFQASIaSlMWAhQtfVbfjL7AsbSZvmz4PNoni1H39x2nm+aIoMiJ I/UNvkj6CGrA4Xycm3nK/vgywaQG/5NngcBGPqJUTmxII9/cMdyoNWCPtPCc5g1LQ0dt /qgtoTaLbwpDQg+nJWqf2zQJ8JnjKWG9bhdx9DErIK872VyUa30JBB3Seq46IVbgw9RU UqFg== 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:cc:to:subject:user-agent:mime-version:date:message-id; bh=ig4Ip3xFURcna0FEPQNJfflXkAYnSJJ2VrU80FOqccU=; b=syDwCuzqk1gCw53RiyP54yRdaqiKY2oxfFF5TZEQaGSu76AW8eUt6+KcsmRt2NXX6/ 7SGrDY5KghL2oazkGKoVaK3YB92mZKJwA91/NoKHP5uwBsLMnzlMHnXU8lkNOUmj3rCO A6TuEiirDXgjqEN1ytbB4VW6zQV4SZJFqmYUhP3pFQbnEgC9GclRpZBr2RZ0YhOqHE4q Mv2l1x89hmnYbsw8PANbniEPt3EhELXtq6c5rCbzFg5gpT0di3UEw40bLly+AF1K5UNp 7pCZRhCF58qOypb2pzAy8VIQDg0uuwtO6ihhkEyn3jpjMXFGzEWReeWY9pbKtvIm0DpU kMqg== 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 l13-20020a170903120d00b001b231cb6f22si4258031plh.111.2023.06.21.02.23.46; Wed, 21 Jun 2023 02:23:59 -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 S230365AbjFUJMd (ORCPT + 99 others); Wed, 21 Jun 2023 05:12:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231283AbjFUJLh (ORCPT ); Wed, 21 Jun 2023 05:11:37 -0400 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6943E19B4 for ; Wed, 21 Jun 2023 02:10:58 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R821e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VlfKbH7_1687338654; Received: from 30.97.48.59(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VlfKbH7_1687338654) by smtp.aliyun-inc.com; Wed, 21 Jun 2023 17:10:55 +0800 Message-ID: <58d0d829-da04-0f77-eedf-8bfa519b52f0@linux.alibaba.com> Date: Wed, 21 Jun 2023 17:11:15 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH -next v2 1/2] mm: compaction: convert to use a folio in isolate_migratepages_block() To: Kefeng Wang , akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, willy@infradead.org, jgowans@amazon.com, yuzhao@google.com References: <20230619110718.65679-1-wangkefeng.wang@huawei.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,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 6/21/2023 4:36 PM, Kefeng Wang wrote: > > > On 2023/6/21 14:20, Baolin Wang wrote: >> Hi >> >> On 6/19/2023 7:07 PM, Kefeng Wang wrote: >>> Directly use a folio instead of page_folio() when page successfully >>> isolated (hugepage and movable page) and after folio_get_nontail_page(), >>> which removes several calls to compound_head(). >>> >>> Signed-off-by: Kefeng Wang >>> --- >>> v2: >>> - update comments and use node_stat_mod_folio, per Matthew Wilcox >>> - add missed PageLRU conversion and rebase on next-20230619 >>> >>>   mm/compaction.c | 84 ++++++++++++++++++++++++++----------------------- >>>   1 file changed, 44 insertions(+), 40 deletions(-) >>> >>> diff --git a/mm/compaction.c b/mm/compaction.c >>> index 6149a2d324be..0334eefe4bfa 100644 >>> --- a/mm/compaction.c >>> +++ b/mm/compaction.c >>> @@ -795,6 +795,7 @@ isolate_migratepages_block(struct compact_control >>> *cc, unsigned long low_pfn, >>>       struct lruvec *lruvec; >>>       unsigned long flags = 0; >>>       struct lruvec *locked = NULL; >>> +    struct folio *folio = NULL; >>>       struct page *page = NULL, *valid_page = NULL; >>>       struct address_space *mapping; >>>       unsigned long start_pfn = low_pfn; >>> @@ -891,7 +892,7 @@ isolate_migratepages_block(struct compact_control >>> *cc, unsigned long low_pfn, >>>           if (!valid_page && pageblock_aligned(low_pfn)) { >>>               if (!isolation_suitable(cc, page)) { >>>                   low_pfn = end_pfn; >>> -                page = NULL; >>> +                folio = NULL; >>>                   goto isolate_abort; >>>               } >>>               valid_page = page; >>> @@ -923,7 +924,8 @@ isolate_migratepages_block(struct compact_control >>> *cc, unsigned long low_pfn, >>>                    * Hugepage was successfully isolated and placed >>>                    * on the cc->migratepages list. >>>                    */ >>> -                low_pfn += compound_nr(page) - 1; >>> +                folio = page_folio(page); >>> +                low_pfn += folio_nr_pages(folio) - 1; >>>                   goto isolate_success_no_list; >>>               } >>> @@ -991,8 +993,10 @@ isolate_migratepages_block(struct >>> compact_control *cc, unsigned long low_pfn, >>>                       locked = NULL; >>>                   } >>> -                if (isolate_movable_page(page, mode)) >>> +                if (isolate_movable_page(page, mode)) { >>> +                    folio = page_folio(page); >>>                       goto isolate_success; >>> +                } >>>               } >>>               goto isolate_fail; >>> @@ -1003,7 +1007,8 @@ isolate_migratepages_block(struct >>> compact_control *cc, unsigned long low_pfn, >>>            * sure the page is not being freed elsewhere -- the >>>            * page release code relies on it. >>>            */ >>> -        if (unlikely(!get_page_unless_zero(page))) >>> +        folio = folio_get_nontail_page(page); >> >> I'm just curious, how can you make sure the 'page' is not a tail page? >> Since the validation is lockless. > > folio_get_nontail_page is added by commit "3c1ea2c729ef (mm: add > folio_get_nontail_page())", see more comments [1] > > [1] https://lore.kernel.org/lkml/Y86sRiKAAOz2myNe@casper.infradead.org/ I see. Thanks for sharing. The changes look good to me at least. Please feel free to add: Reviewed-by: Baolin Wang