Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11282545rwl; Mon, 2 Jan 2023 18:13:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXtYw1JN0Py5EXkf4P8Me2WFAo6v3spBcKq1TB2eZ/VcK4VO4bwohlu1Dks3AhrORGiFOjmF X-Received: by 2002:a05:6402:b6c:b0:48b:8e65:6029 with SMTP id cb12-20020a0564020b6c00b0048b8e656029mr8513901edb.26.1672712023862; Mon, 02 Jan 2023 18:13:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672712023; cv=none; d=google.com; s=arc-20160816; b=Wp/wBK/0fzuYyCmFIilq/benTGDhq6b+OyzTvcK5dWC7YGbJzb/t5TEKk8UH1sfdAA UcXGpKPCRJo14+H/iRbb1biEQw2IPa0c+zZN8h1rQMmjZP/54w+bUjQSXV5UXZmJLwrJ 911CaslXcvQyavKjUTER38/PL6sVuIkScn+DGAVXvUYhhnV2tq7MZXbBcpge0k7v9PqH 16DLShDN4ABldtZldtlpZ47hB5YEeWRTtTULRQW0CbN85brDo+5EYLlmnvdaRNlM/d/A CzzeLg7aLteVn6QhjiUz0vE4ufbaaFrGopOl06VOFKgxh+xEJy2+ZDJMjterT2KuNRQD FvSQ== 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:content-language:subject:user-agent:mime-version :date:message-id; bh=mlY8BcRKB6Imye5nEqt+avZrD4uN3xeA9z+o1kQdk+w=; b=dw/APsR5fAe0kE+xSlOsy7Kuu6TUlgmnQ/9RQTBlZ1eJ3FE7v5JS68tb0aWfyW7FHP wYrv1VC43GNLnH3sto6cmwYhRnBQ1jnrcEu1iU2PK9zbIEsc6nPXxyJ+HyV2tTjsl7So Y9putwAm38nkDabI3O1gG67LY81hsun0HzO8r4BViVa3xgkeypH8WWuVZ78ZhMZmmkpW Tr9DEJ9DgPIDc19dszTtzdsczXYupJJGMiOXzA++JBUXlCHoBO5K4KKWWGXsq4KqX8E7 MQ4cDwiWqQ60dGHq2GfrEj2E2LNUou+47zrXhTdOfbbSrcdMvaMqlXPdEg/idR5tvxyR 5JAw== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y17-20020a056402441100b0046bf2cb7a3asi29829981eda.578.2023.01.02.18.13.28; Mon, 02 Jan 2023 18:13:43 -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; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236576AbjACB6m (ORCPT + 63 others); Mon, 2 Jan 2023 20:58:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232893AbjACB6j (ORCPT ); Mon, 2 Jan 2023 20:58:39 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3494127 for ; Mon, 2 Jan 2023 17:58:38 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NmG863QvMzJqnq; Tue, 3 Jan 2023 09:57:26 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 3 Jan 2023 09:58:37 +0800 Message-ID: Date: Tue, 3 Jan 2023 09:58:36 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH v2] mm: huge_memory: convert split_huge_pages_all() to use a folio Content-Language: en-US To: Andrew Morton CC: , , References: <20221230093020.9664-1-wangkefeng.wang@huawei.com> <20221230134535.240f49e0ad8bf6d82f8cc393@linux-foundation.org> From: Kefeng Wang In-Reply-To: <20221230134535.240f49e0ad8bf6d82f8cc393@linux-foundation.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 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?