Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1765354rwl; Thu, 5 Jan 2023 19:43:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXvnjJ77dtEVWZxifPHggWUOeJMT59F6nLgwLtfI3GNfPftzO8KAfxJlpHF/HEq5oFP9zaOr X-Received: by 2002:a05:6402:249e:b0:472:c7fe:475e with SMTP id q30-20020a056402249e00b00472c7fe475emr51687734eda.27.1672976594811; Thu, 05 Jan 2023 19:43:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672976594; cv=none; d=google.com; s=arc-20160816; b=bSEFtKgsyLPkSNqqn5tAjcvUeXMaoBS2haqAkGoANoPqXgchliQJuqEsOFmHyfmE6P Qsuwfp7/a9dr8rRJzGdYWBH0DszXpEBMbCLPd/BPGxX6E2X3+6O0z3CwuG6daNf6tOp+ bcAeH6expFElGvxp2GYtmFydJVVGJ9a0rUvqqipDkU32M+/1Yi3EQ2PTTx/VFPiLngB9 Uyg9j5dJW8vIvarZxLWLoCUbDtLBJpiBOa3csNwErfPKkR5nOvwYIAzV3pgVwrx8EsIt y146+bSn7U0Ui5IABpMNvoQiACBFdc3lmRemUbBc7/BdGYIcGSmvKyQzuQg+FSjxJI+k VC4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=fwTsOtfJk4TE+10VvceumnwAFjpmJFjl6ST1emuEzqA=; b=WV3MYV382p+DbHOCkOL0L2b89ROJl5ORWoi9UuNImumCgaY5bSXEIQ/k19b/0y1Y+D XD52xmmyNdd2A2gLIQR2ZuY/7lPTTiI70V1ik/X6X9S35r7LVrw3MmckD1EPw74RtGkl tIsE947s71SUGEFslowoLZ11dAYiU3BHF68/Q+jFeXt3ouagVOiUW4lWcsZanUpflyiv n5WLCYFv9neeQgIIhLvarKTogTSK7Cuj+yTgAIcJzUCE6uCDbchX2d1hgzlylTnEzi0W LmolyzbKEz9a2yiB0j8W9VZYjiqPE6phEFXJ8S7LZWiF3qIHert5eg7zpl0SA/aSOn4M +pJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=cXeVw7io; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a24-20020a50ff18000000b0046db4826047si179947edu.341.2023.01.05.19.43.02; Thu, 05 Jan 2023 19:43:14 -0800 (PST) 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; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=cXeVw7io; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230264AbjAFDHK (ORCPT + 55 others); Thu, 5 Jan 2023 22:07:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231846AbjAFDHC (ORCPT ); Thu, 5 Jan 2023 22:07:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F1356142 for ; Thu, 5 Jan 2023 19:07:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A69E761583 for ; Fri, 6 Jan 2023 03:06:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E61F9C433D2; Fri, 6 Jan 2023 03:06:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1672974419; bh=T+DIgbx0TN06FPH+vlHy8WVMyBolsDeruztbB4dJxSE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cXeVw7iowabcjhBfgLE1p17wdUYlLu1BgeVeQQ8UijZw7aI95QojB3rMCKd0tjW7Y WS3j63R9NOLu1FknBmCFXsF/VkCZEPzx0EcXBFtP3y3dhfWN+R/ebd8DqZaMkF3uO5 eBRXwFJreXb5DVfS3fu2FD2CBr7qnyP0PJ/Y2LgI= Date: Thu, 5 Jan 2023 19:06:58 -0800 From: Andrew Morton To: Kefeng Wang Cc: , , Subject: Re: [PATCH v2] mm: huge_memory: convert split_huge_pages_all() to use a folio Message-Id: <20230105190658.f5d9a4bc9619ad6bec91a973@linux-foundation.org> In-Reply-To: References: <20221230093020.9664-1-wangkefeng.wang@huawei.com> <20221230134535.240f49e0ad8bf6d82f8cc393@linux-foundation.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Tue, 3 Jan 2023 09:58:36 +0800 Kefeng Wang wrote: > > > On 2022/12/31 5:45, Andrew Morton wrote: > > On Fri, 30 Dec 2022 17:30:20 +0800 Kefeng Wang wrote: > > > >> Straightforwardly convert split_huge_pages_all() to use a folio. > >> > >> ... > >> > >> --- a/mm/huge_memory.c > >> +++ b/mm/huge_memory.c > >> @@ -2932,6 +2932,7 @@ static void split_huge_pages_all(void) > >> { > >> struct zone *zone; > >> struct page *page; > >> + struct folio *folio; > >> unsigned long pfn, max_zone_pfn; > >> unsigned long total = 0, split = 0; > >> > >> @@ -2944,24 +2945,32 @@ static void split_huge_pages_all(void) > >> int nr_pages; > >> > >> page = pfn_to_online_page(pfn); > >> - if (!page || !get_page_unless_zero(page)) > >> + if (!page || PageTail(page)) > >> + continue; > >> + folio = page_folio(page); > >> + if (!folio_try_get(folio)) > >> continue; > >> > >> - if (zone != page_zone(page)) > >> + if (unlikely(page_folio(page) != folio)) > >> + goto next; > >> + > >> + if (zone != folio_zone(folio)) > >> goto next; > > > > I'm still not understanding the above hunk. Why is the > > "page_folio(page) != folio" check added? Should it be commented? > > There is a comment in try_get_folio(), is it enough? Nobody would think to look at a private function in gup.c. I suggest this folio_try_get() rule be documented at the folio_try_get() implementation site. Most callers do perform this check, but not the ones in vmscan.c?