From patchwork Thu Dec 29 12:25:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 37368 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2370681wrt; Thu, 29 Dec 2022 04:17:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXvYcwxdum/BwWxne8mDdZ9STs+kIbAK2b0sNWDi0MV6J6lTvmhvHcJOo/65mu7SL6GbpflO X-Received: by 2002:a17:903:1306:b0:192:5ec4:c439 with SMTP id iy6-20020a170903130600b001925ec4c439mr22020070plb.16.1672316223785; Thu, 29 Dec 2022 04:17:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672316223; cv=none; d=google.com; s=arc-20160816; b=HFpLaXQrXDChP8MhSR0INOgEx7Q1T1kfRthOcBhWBmBNqnVmtPm+8zKTcVoLXGOGqh qHJiMkuB59qnslJ1NzvC84TSB3x7ySfWNg8dDnmAyFsxHBCceT7Xm25L9wRh72welKPr Evf4/At+9gYOIdpuLYkzEvlqoJyrqezeA7qeJ/iS+EQK4q7FFBiyqhOmoo/py0snu0p4 FVO9FYxt/Jf16Y6VV8aavVpP8InqntbhSa6dhYjPwJiLOQLsoliu6w8ZNC7dFZIleMGF z7i+3PK9wz9IfxMah+RkIMZvpqUOVjt74lCGbL15N7AkqNk2aPqzKW2U8tr61V4ZU4d0 lFQA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o11-20020a170902778b00b00192a622ef72si322016pll.454.2022.12.29.04.16.51; Thu, 29 Dec 2022 04:17:03 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753550656570501476?= X-GMAIL-MSGID: =?utf-8?q?1753550656570501476?= 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(); } }