From patchwork Fri Dec 30 09:30:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 37614 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2803418wrt; Fri, 30 Dec 2022 01:16:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXvmBMz/RDppEVdWB4uOu+oXHlybTIN/JgfuvysT8MVlhVlzW50RMTAnFyN7kcxgaxFD0i39 X-Received: by 2002:a05:6a20:a59c:b0:a2:17a6:3e86 with SMTP id bc28-20020a056a20a59c00b000a217a63e86mr38406623pzb.55.1672391815099; Fri, 30 Dec 2022 01:16:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672391815; cv=none; d=google.com; s=arc-20160816; b=EIhWOvZtQ7qz8n3/K3hd6gq3Sq/AQ/b+kAiZPL50r12uund/Gl8PaLyDoRvuId0jF4 kGk6bs3alRaUehVnH9W3kdqddRbbon61qiHBlmaZeIjBSPiLtMnlDkqHYV/m6pAVPCuT TTKrBmGVY8ceeo0eBuDCbRwdoEERmhu1/HLg4bYVzp34NfEgdzXRCsWV+zG6TUX60pk4 azUrxKKcuWrrei8Z0uzLq5jiIUFrhZ7E6Mycgr46UCpufNLUAUpKaP9UA92E5CYPLTLA 4eElunbKVDIL2DfbhmhxuCbfaykSAWpYcNPR+0ReLGOK1E2lYh0aCrLhoD2H9WOS/Zf+ m/mg== 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=6GDIl0xxRXchAmpmDEzUrd3Intb+Oi0grqnalTDitTs=; b=R0d51Cpr8s4dJKnTZMIMwadeMU3nPn8fcj9GRQYpYIWILH0rHBFuuLxUPJ4j24jP58 yLRXjMrlle8l6V6L06Jvu6awxKO9fnEYh1S1Vdn3dVtfJbPmlP0vZ2i0RQwR55EK/ynS eTqjYXiSmf2pJn8RiyP075X6q+OxFFLUUnTEaH71lURXverqueaySgu4X2uUOplsYCfX MJ57HY3BMR8N2pcGVr7CzjOnvQiCxaTNBrDmm1W2YxnVB5rUKnDmHHI/La+wdlVUq6Hg ylNQOf6h/b4bwyu21WjsDuW+nQryQ7MPc6Z2cLs0jI3Nk8lVZBtZicUwOp55F2UQ+NF4 jbvw== 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 c10-20020a655a8a000000b004779a46d07csi21790259pgt.183.2022.12.30.01.16.42; Fri, 30 Dec 2022 01:16:55 -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 S234720AbiL3JOh (ORCPT + 99 others); Fri, 30 Dec 2022 04:14:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234534AbiL3JOg (ORCPT ); Fri, 30 Dec 2022 04:14:36 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E4BA192B4 for ; Fri, 30 Dec 2022 01:14:35 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Njzx33NcrzqTL2; Fri, 30 Dec 2022 17:09:59 +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; Fri, 30 Dec 2022 17:14:33 +0800 From: Kefeng Wang To: Andrew Morton , CC: , , Kefeng Wang Subject: [PATCH v2] mm: huge_memory: convert split_huge_pages_all() to use a folio Date: Fri, 30 Dec 2022 17:30:20 +0800 Message-ID: <20221230093020.9664-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?1753629919845904374?= Straightforwardly convert split_huge_pages_all() to use a folio. Signed-off-by: Kefeng Wang --- - adjust indenting of code pointed by Matthew 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..46e86293935b 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(); } }