Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp7747278rwl; Fri, 30 Dec 2022 13:59:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXuLaqWEuCuShHF2dJCdOpvT1mvwm3dTmKsJK/fiG64Ss+pgKQImGACH4ssWaP9KDkDsBlaS X-Received: by 2002:a17:906:3bc7:b0:7c0:db61:dbd5 with SMTP id v7-20020a1709063bc700b007c0db61dbd5mr27411780ejf.62.1672437555433; Fri, 30 Dec 2022 13:59:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672437555; cv=none; d=google.com; s=arc-20160816; b=I1+PLJ2Xexdr9lnyOWrAH71MNmLhCkM9pBPlMnLNiRQKvvEmVMx/3yz9vA9JtLlMtN Bbo9M8E/TgW04GoFY75YAOap9kRQS/RqH2xZ8ZBass0NFp5AzRZwUA/5fTiTuNxxlPB/ Wfv+65atIxnKSgNSLYFArr3XI52vQI/uO8BCSN97JWpgze4zWsthQr0Z1mrxaqlZQz9m FPi2M0gLKIyByldvm+gqftudCwgA3wonRVO9NYonPihb9OIygyFjPtU9fmz6dPf80g+5 3B0Cok+yu15QgpJg3DOgI5+/O+qHCRT8jP8enAnWVfOW9PG4gRT1UULE6oWscvunvns4 txzQ== 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=77TGjesLms8GJlPT18Lts6DxutB1PQryHVXZeNmikq4=; b=y4zXwAKUQImxDYSWc+h0iJPvKZ0K1IJQYdj6MnkHPGAJkDmDgfJhTH2X23Ya94tS/e VU1dSWEjzYmNLk5sCnPgMw5yqGXk0RsFjARMPiAsmFw17iI1MfAGza0KjeKkoYtizbm3 b7KRuPize6PnBFypBtxEhAphwG+/VROMkTNfPRbrOp2kbRCD/vk8V79MnCaCUYwoVOM+ 6ZlVyYrQ3m3B/gwwmTuoz7inZNKjS/R30UhUWwxPngWYrp58oZH8Ifu6jqpCTN8E7M37 5tvwB0/5MCNW5ubQGuptVYQBEa0Y8XxxLZhPdBpywq555oPednhImosRit64EnCeP9+P PdRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=QZEU0Xf0; 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 nc23-20020a1709071c1700b007f38bd15f5asi19353825ejc.349.2022.12.30.13.59.01; Fri, 30 Dec 2022 13:59:15 -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=QZEU0Xf0; 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 S231363AbiL3Vpn (ORCPT + 63 others); Fri, 30 Dec 2022 16:45:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbiL3Vpk (ORCPT ); Fri, 30 Dec 2022 16:45:40 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E4A91B1D4 for ; Fri, 30 Dec 2022 13:45:39 -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 ams.source.kernel.org (Postfix) with ESMTPS id 3EC2AB81C25 for ; Fri, 30 Dec 2022 21:45:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A096AC433EF; Fri, 30 Dec 2022 21:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1672436736; bh=cVumx4Nm/N9nn3OVGA7It+mlETPOyLHvs1Havnr2L+A=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QZEU0Xf08tqRC03cMUp8ZVX2PqiCbdTTp/+3KWjVK6nFZli66GShQzIkgdGTev7A1 97qHlLG6zRpYCC30idfLCXk3IWs+OGJwp+KQxv1Frl7MFtMpI65euANI7IqJx4ev2m mI9fkU9sqboXIdOLqXkFAhCPyrE6v4yfTjbVKXRs= Date: Fri, 30 Dec 2022 13:45:35 -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: <20221230134535.240f49e0ad8bf6d82f8cc393@linux-foundation.org> In-Reply-To: <20221230093020.9664-1-wangkefeng.wang@huawei.com> References: <20221230093020.9664-1-wangkefeng.wang@huawei.com> 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=-8.2 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 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? > - if (!PageHead(page) || PageHuge(page) || !PageLRU(page)) > + if (!folio_test_large(folio) || > + folio_test_hugetlb(folio) || > + !folio_test_lru(folio)) > goto next; > > total++; > - lock_page(page); > - nr_pages = thp_nr_pages(page); > - if (!split_huge_page(page)) > + folio_lock(folio); > + nr_pages = folio_nr_pages(folio); > + if (!split_folio(folio)) > split++; > pfn += nr_pages - 1; > - unlock_page(page); > + folio_unlock(folio); > next: > - put_page(page); > + folio_put(folio); > cond_resched(); > } > } > -- > 2.35.3