Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6986972rwl; Fri, 30 Dec 2022 01:33:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXs4lJLVvKbqxvDiv4xSBPUxXGehehsVaOv5HUWPf5uKYpTgyBVaaxLp6W+KIwyJ0vL7gnPn X-Received: by 2002:a17:902:8f86:b0:191:282:5d6c with SMTP id z6-20020a1709028f8600b0019102825d6cmr36848693plo.61.1672392836725; Fri, 30 Dec 2022 01:33:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672392836; cv=none; d=google.com; s=arc-20160816; b=z81op+l7EWsaHGBxZDIl5zS0kw9nztiehfEDzGgFOQIQQ5mydbyyfTJYbX/XHhIW9r SRs9XGHI+fo5WFZ0GFo18sJF2h1QjrmTAtmi6gIkiJcHSjtqbYA5ikk2WLSb981nAaO5 9GitFnUeuIV76cx5nskEUad/ASQ1ZhPeoiJlN6wnRi8j0qmPLO0oSFrYyPJP+d2qShMS 3CksmVNlwVE12+3tzGg9D1wztlwBevzxq8Fo2SHxDYgkeJbPvL08dBMNlXCyCK9+JhtA KHuFtUii8475dykGRfWH7TAAVeSD9eK2kCrbeyKaxjLyszxT7VmEWwaj8d/Tf84Hznx4 ur7A== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e5-20020a170902f1c500b00186b287bd57si20186560plc.190.2022.12.30.01.33.45; Fri, 30 Dec 2022 01:33:56 -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 + 64 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 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 --- - 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(); } } -- 2.35.3