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: 13084230 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4464C4167B for ; Fri, 30 Dec 2022 09:14:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 248198E0002; Fri, 30 Dec 2022 04:14:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D09B8E0001; Fri, 30 Dec 2022 04:14:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 071598E0002; Fri, 30 Dec 2022 04:14:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E954E8E0001 for ; Fri, 30 Dec 2022 04:14:41 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B693A1A06F8 for ; Fri, 30 Dec 2022 09:14:41 +0000 (UTC) X-FDA: 80298412362.26.DE5574A Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf08.hostedemail.com (Postfix) with ESMTP id 97561160002 for ; Fri, 30 Dec 2022 09:14:38 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672391680; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=6GDIl0xxRXchAmpmDEzUrd3Intb+Oi0grqnalTDitTs=; b=JZwHjLOj/RF6JjWz4jw+ZpNnAwRgUidLbLRQ0UA2y9iamYAO/rouaUHK5JM47y17bsTxJ1 wbcf8UzZC4EbzYZxu1DDGuC+l95CqpBu63YXFi13wk3e7U7tH11nj+vDdM1cS++vCl7RDT kHgNFrpVqq0ySbsnaoEqnbNjjvpvuPQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672391680; a=rsa-sha256; cv=none; b=2ScdDkViLE3rAu5fMzgigiRT2INkhKlY6UE+VHeaz65DjOrrJuDs+8hrVw2ZLzKUBbkNyi B161HLOZJ/LhEOP3lzj2qaMvLMxAuNKhGCMP7WknXCUaVAUeM+vJ2f8p/bn+SJAAvC2SsA Q1UZS/f1kCh1vWnn3yWMsbtBSiUjCvE= 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-Rspamd-Queue-Id: 97561160002 X-Stat-Signature: ce43o3wxn5o3e67gjy1jba1mop9jq8pi X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1672391678-179445 X-HE-Meta: U2FsdGVkX198f+yeNSzsQTxSMQMuMXe0gzC3g6t2mgeaASZLz7Ls1WXXlBAE26RWhbyFpvCGUsau5pHzonKaEPNMrCG6xc9MyYPpavqEUIr8ooC7Z/zfuFK4SEhhzPfGmEXxFiegWtWinsGrr9VKK73OxSt9IhIVnYVb9mrwvY05Vd6Rg7oGhzsC9VKKdva2sA4dy8nVFp9zivGQrQDBxG/3YoxjXLZKRI86FMixCUFcZR2z6zxn6JPwXQ5lzXBtkmh0OW7I9YGGA3hkowTVr2tKFOfZB1Ib64Xa/4rT6H0BGj9V3kX/Ku+RF/1FNGQiKtveIsdql2LWteqS7+CcLr4vGy+JLcBPNV302MLaSQFXYAWlmRGBGgbCOzky4NLqbo+oK7v3jyWBMd20cViNkCGuZ1KrZXMvMUlNWcD0vtSir2tn2pM3lepfsAJDJYyjivZzsAIgDhqf1KppOkipXFXaUOyjDgJ5AJKF/ibJRbOhS5h7Du/sYtY7/4YIyDPB+MYT9jt8bNxpn3MlF80cnj42S0/QRSb/QWw+DDiZMlR+MvPi1idJuz/qGrhi2wdfASeL9XLNL/VIbzHOe5eGhece+7sQLUyQ3ZkLlB5YYg+oT0WxLkpcOudkzDh+DasaltCtRV/MjJ2q6FfbyTmP5bcFBBrxCTpuJbE+mhhHRY+7lHPn+8VPlgwW7TdjVQcR+OZBlzpGDZvtAsXX1vGFN1/ThMgaSeQcRgxHAA22eAHT+nFf1Mj5vVn/WvIh1yUCW/3y7y1p5bn4DyHHHSQ2/f3bOLkoWelJYPM+icBc/nNnjNSHKJajOO/3BU3OZrkenTJ9YptFNi2zgVxRfxKWqUQj18eGekwhNZ7664YL5DO3pi5GsS6VKjN0wx4OQCwcjPycRZANVkD3jUKOtkqiWBrjGui+tv+p X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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(); } }