Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5882676rwl; Thu, 29 Dec 2022 04:34:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXuJ/rbPKp0UNX2NRrlRYYQQQm06s5iKZYrQKE9gA3od+34WMi6AI0q2nU1EYAhJK6CbE0R4 X-Received: by 2002:a05:6a21:c08d:b0:af:f1d1:6f7f with SMTP id bn13-20020a056a21c08d00b000aff1d16f7fmr39008407pzc.31.1672317248485; Thu, 29 Dec 2022 04:34:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672317248; cv=none; d=google.com; s=arc-20160816; b=sI/E7vBjNakgPYykgyIBI8DRNq+gwJa3LkFuunu0+90RKH7yZRSGuI5BQSnJP8A2Nq UIvw6UZuXoeRrrOjIJXTC05Cri5i3uoh3268d7Z9AkM9Ldim0gz+M4Brq5CbY9sCQbnD 8bdyx1ftaFfOrTFVCWPPS/9mE+PQLmbEy2G0xY8B90rmVjtcr2UUjY+KMDF1VpnO2tQ2 norS0TwT5hAEe6GC5WG64uC+Olu5XzaIfFIMQqP2REyOliv7eAUvHwNrVmpIGlD+bfl4 wgg6De/WVhNwXCLn0HcDgrKr56FleYFVRjKwyzWclVBuyMLf+8qTsjVUqSn2Ep8b7pEN ht4Q== 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 :message-id:date:subject:cc:to:from; bh=B1a8gHeys/ZFdqQ8Q/MTcgGouU50qVaXrm6uPQjvMJ4=; b=CmpikJdXouA3SQmCmoqqEM6lH8xH64VLxhGHujGrdUwp1vfTITlvrSAF8ULK1Sgsuw 8j8RjA/vqMfcVAqXCPlul6+V/8EH+0Mv7E8J5z+0Zl9nad62aIoBtZNtAcuANoR6jFTW gR+ORJ3xEjnXsF0j8wWrg04y8YrCmq7dru/QvhHFizvNg3iKbeD1wT2mkp+HA5+61+9w fu9qziiGjZjsIOJyu7105Js8EwyCi9iEznnxmq9dAszbJO4Uphx2ec7QNpU0Q1BY6dV9 81rOuVALcs7iB1nSqQU7UpFwe5lMZjyYQDMkm9MP/j5+oUafHFgIvDv4BdHp26WXOJ8H 8ASg== 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 5-20020a630405000000b004776a50bd21si19329612pge.579.2022.12.29.04.34.00; Thu, 29 Dec 2022 04:34:08 -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 S230458AbiL2MJl (ORCPT + 62 others); Thu, 29 Dec 2022 07:09:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbiL2MJi (ORCPT ); Thu, 29 Dec 2022 07:09:38 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39F885FFA for ; Thu, 29 Dec 2022 04:09:37 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NjRxC1SFtz16LvT; Thu, 29 Dec 2022 20:08:15 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) 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; Thu, 29 Dec 2022 20:09:32 +0800 From: Kefeng Wang To: Andrew Morton , CC: , , Kefeng Wang Subject: [PATCH] mm: huge_memory: convert split_huge_pages_all() to use a folio Date: Thu, 29 Dec 2022 20:25:03 +0800 Message-ID: <20221229122503.149083-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,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 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; + 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; - 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