From patchwork Mon Nov 6 15:49:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13447136 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 EB3DEC0018C for ; Mon, 6 Nov 2023 15:50:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D9EE8D0025; Mon, 6 Nov 2023 10:50:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6AF6A8D0024; Mon, 6 Nov 2023 10:50:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50FF08D0025; Mon, 6 Nov 2023 10:50:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3AA1B8D0002 for ; Mon, 6 Nov 2023 10:50:10 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 0E12BA0585 for ; Mon, 6 Nov 2023 15:50:10 +0000 (UTC) X-FDA: 81427965780.18.5410BB6 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf04.hostedemail.com (Postfix) with ESMTP id D75574002B for ; Mon, 6 Nov 2023 15:50:06 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1699285807; 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:in-reply-to:references:references; bh=MPGmfuGIWa6O6otMqJXbXH0YFlYM5vFEP+zlcU8Yh7w=; b=Vo0QAjPaOOwhRX85dvlJsEoLmU0MnwVHq2ck4lb4vz97u8cOc/XB0NESotpUNfeQ1EF7+h b4315jNqKigTaAG8zhASIJ924Mwg3ORfx0Eca9eM7suUqwvFlGuyDsDs6Pxn1JSXOYQgy1 wmKF7Ie22pdDlEod8gKhaS6Tmpj3434= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699285807; a=rsa-sha256; cv=none; b=rS8TdAmS6ctpDGHvcXZkkiFgvhcEFTh1ECMgFBR0JGbGC5yRSgYmWOQsbanI8UOQxDKFQY 5141Ld4ByCIZJlbPF/t/30SgBTvhl1BkHIn+Isw7b52/Hqhc6idjRkEBm4/p151paeTCH6 O54nPT9KKBBRFoawJMRJ57DTkCq7E1A= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SPG1S1t8Mz1P7vj; Mon, 6 Nov 2023 23:46:52 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 6 Nov 2023 23:49:59 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 03/10] mm: huge_memory: use a folio in __split_huge_pmd_locked() Date: Mon, 6 Nov 2023 23:49:43 +0800 Message-ID: <20231106154950.3399469-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231106154950.3399469-1-wangkefeng.wang@huawei.com> References: <20231106154950.3399469-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: D75574002B X-Stat-Signature: jhhhiztfh1eqb5571o6jpbo9ndsmrsc6 X-Rspam-User: X-HE-Tag: 1699285806-167049 X-HE-Meta: U2FsdGVkX1/hVgXLX8nhOcPYOVjhliI2lKnCgxDsqCovPR0Z5GY0zGL3B8OkPBmXwZxii1oTo5KWK980wI7wBRZFTEAng73dzp/RzYdW+pncuCs8DHRI3Fuur9qJlv7+ZF18lu4ZeCE+7FMgrI1rcOUr+S5+WI6Cfdo65gsJEOoVI6nSf3r79krHKEvkm81tl1CYVvOAQ/6Z/Zj8aoxaUHpcUOB2G/+HKkIPso7Uuz+L7hbJxXNI7UaZAGRQloivY60e6vaGbw0HAgXLwCu9VwmoZAwrweQ0ojyUYaXHtCAQScdyAme0kYeBA0eUAVyCfs6Qq7aFP63hGmerPGOLud4fn+vD86MsskNkeBjRXsY3otdSC2W4fCxGLIGy1ucBxu7rJ9w2dQhqzl7UVLNVLPwVah5MhqmRgqvL48I8vLRKwjhz1prZNC4GTxkSWBwkdWqDUSK+gNOpQ/CNiOUbCGB8BexfRanqqzKvOxTW0ZMHCXK32Z+Mq10p4iapexhYkR2rFRpRxsDWyU6JwKSYFJ9rfzbuGUrxunDz2PiSWBy5j4NSHL1r8DrdPwn116N5P50AR6/+kOmk8rPYFZ0aA6hf9V0q+wSyv08JYfu2V9jhwhZyY35xqp3UDLuyR4ADW6wwFs6M1LLr1Q6mg3bxWaA5qS8k5m1rNiSQs2Gv4xkYdH8saqzwNmfkNs98tHFa4FNGnJt2/sFEutfUXvYtwK9WVQagGaNA2AMI10/Ovh0f49JcEpKHm6urLhflOS51o66eyuAgAsA0pesw3A+2h9xJoNUTzG8UZ92lTW9QxkPXEvTcUdNRwIlCDQGnKC6M7HxvXNNOOxWjyCJ9RM/8Q5Tp3MOzuzmnaTzoSW/gGCxGgcRDs1lkqqCA3R+fCM7J5X30IAaiWVPSDVjuQjbCUa12N26wydlcpcPzpJLycPdadVAXi4gxP7Wdv4LXzJk04lP9WD5Q/2FHTvzmPxx 5SnF8Pkn VA3Aam0gBevfPARg4OlP2XQaZhO6RoYByz+AYIksSqsih24r0gaGMe8vOISFbFRovXw3MiGovhNKBnd5vsoObtcVwJf63XUYBTI16nnKOj+tuebJ33g0MtlNgAy7zzkFXU8UxNbDqZ8GzW73/5E058Qn34pmo11NVoBwRYD256aWIwZ5YUUodtE6wZNL/X5tl54Wp 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: List-Subscribe: List-Unsubscribe: Use a folio in __split_huge_pmd_locked() which replaces five compound_head() call with two page_folio() calls. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index f31f02472396..34dd01970927 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2117,6 +2117,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, count_vm_event(THP_SPLIT_PMD); if (!vma_is_anonymous(vma)) { + struct folio *folio; old_pmd = pmdp_huge_clear_flush(vma, haddr, pmd); /* * We are going to unmap this huge page. So @@ -2130,17 +2131,17 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, swp_entry_t entry; entry = pmd_to_swp_entry(old_pmd); - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_to_folio(entry); } else { - page = pmd_page(old_pmd); - if (!PageDirty(page) && pmd_dirty(old_pmd)) - set_page_dirty(page); - if (!PageReferenced(page) && pmd_young(old_pmd)) - SetPageReferenced(page); - page_remove_rmap(page, vma, true); - put_page(page); + folio = page_folio(pmd_page(old_pmd)); + if (!folio_test_dirty(folio) && pmd_dirty(old_pmd)) + folio_set_dirty(folio); + if (!folio_test_referenced(folio) && pmd_young(old_pmd)) + folio_set_referenced(folio); + page_remove_rmap(&folio->page, vma, true); + folio_put(folio); } - add_mm_counter(mm, mm_counter_file(page), -HPAGE_PMD_NR); + add_mm_counter(mm, mm_counter_file(&folio->page), -HPAGE_PMD_NR); return; }