Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6629188rwl; Thu, 29 Dec 2022 17:01:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXvGbrA4WTDBIgpUWcU+7t+EzXODkjqzoisjv+FR1YYtA0Cr9COuHHB/qh/qHcNPSCgm61dr X-Received: by 2002:a17:906:1381:b0:844:842a:32f3 with SMTP id f1-20020a170906138100b00844842a32f3mr23725331ejc.58.1672362100455; Thu, 29 Dec 2022 17:01:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672362100; cv=none; d=google.com; s=arc-20160816; b=ma4MjE+Yd6qDaT4EppblD7f8JjVf2HOpvIV6bto7mnDJ0f9G5U1BzF4iQSeQFQF3BJ UKY5S/EwNBRh0CECnVJyT68o3r9NOTtMCzsndv/C87uxI2EU4Bdwxxq5+KuwW3VgmjNl T2o7pscPgSaHZyOLH6oMNtUlt8koT/kzfT3QDQ1h+/QMu9/TNUjH7OxCZIpI5t/2d6fn 2AFCkYbYdytl/Yl9+Uon2mCYVDosz+Y744EoXp3eOYfjROYGkVt2VsT2adztq8D8rDu2 v97L0NVMN6QG+Qp+UPHIpRFp60ebs2ZAiQljx4Pw4EVT4izEUqx02H7C6ic3idZhavDT fdjw== 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=x3u0DqVoDgI6WINRHZblKppTXPtXzAZftK2TaRdYtws=; b=aEHIFVbZ5QRa7JJ8gsCYGFivDkZLj4YHwYjzIjaTllOLv1uFmvI5kRn1n4jcxuU53B VCqV3h4SLbbppWDtePBtP3kGW7aCEKIuZpl4Xc+/+AXeG5os9mmc2FWWn+0kUBuR9tI9 va/8l/QPQke5UPXO577o5LRi2wznFCge4L9XVYrzClNhVg8IvRJkvPBLg7EWNXqv8D40 s41+2uICeEMAWlWzWEpphZ0/MKTqyGOAdYnJFdm9HasetPUy1cCDkGeHNCx/h8lk1KLy +F+o70Qg1oJvPegu/sVFHq9sPxVQSeN+BeSIgvn17wh82YDsYw40JIhULzp19iM+OGd9 WFFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=SUK0ZE5B; 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 wg9-20020a17090705c900b0078dcdbb3e87si16717744ejb.530.2022.12.29.17.01.26; Thu, 29 Dec 2022 17:01:40 -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=SUK0ZE5B; 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 S234185AbiL2X23 (ORCPT + 62 others); Thu, 29 Dec 2022 18:28:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234161AbiL2X2Y (ORCPT ); Thu, 29 Dec 2022 18:28:24 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56009167E4 for ; Thu, 29 Dec 2022 15:28:24 -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 E3F5E61985 for ; Thu, 29 Dec 2022 23:28:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25E15C433EF; Thu, 29 Dec 2022 23:28:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1672356503; bh=hN/O7/DsuJPZHbYIvsoTEdsXX7zDNtXmGUbeZYQ3mIs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=SUK0ZE5BGDKMs5/xALYV1saOFeKVO2nJ8FAJznkv7TQsU68qSa07W/sYlc1kPR6pj dytmpDxpqcnK3icXGgVcwh4PKI62Maekws6/7SIxfdhfet9Ps0PfqZd9YbEMq+BvTZ WFbuwIgw4im7BqFkB2o8w4LQjrikOasuiYlP1OVw= Date: Thu, 29 Dec 2022 15:28:22 -0800 From: Andrew Morton To: Kefeng Wang Cc: , , Subject: Re: [PATCH] mm: huge_memory: convert split_huge_pages_all() to use a folio Message-Id: <20221229152822.a283198e5df331caaac88a55@linux-foundation.org> In-Reply-To: <20221229122503.149083-1-wangkefeng.wang@huawei.com> References: <20221229122503.149083-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 Thu, 29 Dec 2022 20:25:03 +0800 Kefeng Wang wrote: > Straightforwardly convert split_huge_pages_all() to use a folio. > > Signed-off-by: Kefeng Wang > --- > mm/huge_memory.c | 25 +++++++++++++++++-------- > 1 file changed, 17 insertions(+), 8 deletions(-) > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index 266c4b557946..c8cbe7f62eaa 100644 > --- 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; Why is the PageTail() test added? > + folio = page_folio(page); > + if (!folio_try_get(folio)) > continue; > > - if (zone != page_zone(page)) > + if (unlikely(page_folio(page) != folio)) And this? > + goto next; > + > + if (zone != folio_zone(folio)) > goto next; > > - 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(); > } > }