From patchwork Fri Nov 3 14:01:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444566 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 D355AC00A5A for ; Fri, 3 Nov 2023 14:04:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC668280022; Fri, 3 Nov 2023 10:03:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A75FD280021; Fri, 3 Nov 2023 10:03:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87A82280022; Fri, 3 Nov 2023 10:03:58 -0400 (EDT) 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 78E41280021 for ; Fri, 3 Nov 2023 10:03:58 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5063880D0D for ; Fri, 3 Nov 2023 14:03:58 +0000 (UTC) X-FDA: 81416811756.06.98E3594 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf19.hostedemail.com (Postfix) with ESMTP id 520371A0034 for ; Fri, 3 Nov 2023 14:03:53 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699020235; 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=NB5R7sYpytkiUmaxuKrNkniyxkHRPvjeB+cXDTFDb28=; b=mekqGJ0ZwYfNhq20HVIcsa9qnN11pDA0MPNv5Q8MSJJMM0Hcc1CxadD28cbcx0zQdxhYwN QR8SbtQAZ814qD356sE9R2/mkbsZbBRSR8e1Dk3000MuwtCHh0kdQZ++9LPVE1DPAhyYUv IrbsMzlqckol5lZOUTOlcSi454mgoh4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699020235; a=rsa-sha256; cv=none; b=R+h4djWSSWPkfSzK+Ckd66PA+cF+fHGDXosmp8nvIjvmr5Tbd0LzZDS07J8O2CqbV4RAPd +kAmS+pb2bImfGquNKnmKBOWyvKUU/nzPjt9Q0dYsm3aqFY8RHoVxAfVf3RAD65R77Gj3I 1MUWnJtXYKhJVU+PYuHE9uPzgX0HzaI= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpP4lT5z1P7Sl; Fri, 3 Nov 2023 22:00:45 +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; Fri, 3 Nov 2023 22:03:45 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 06/18] mm: huge_memory: use a folio in __split_huge_pmd_locked() Date: Fri, 3 Nov 2023 22:01:07 +0800 Message-ID: <20231103140119.2306578-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 520371A0034 X-Rspam-User: X-Stat-Signature: kuwshm6d716pjum1b3gc3jqofn8eywph X-Rspamd-Server: rspam01 X-HE-Tag: 1699020233-515555 X-HE-Meta: U2FsdGVkX1/VDn55h+creRDJcDIPMHS+86fvPCy7hf3Vz+cRAKX5IGhW52FOVDLwnRuQtV0DRxZTVbuznH2AN7u+Kffwy2SeVaXltPvPU2AecuUGFCcuwk0+23ykQDT6CtUy1pP17NLDSsBOhQ0bFareENoF2iNPky5YcvyIv+ZQdli0ezKHozxacz0PKKRTHNhkjyW8JKpDVeCM2VVmkK56sQFB/C1EraHxqPk7eS6/JvWrmNhJo9Uibw9aJNYqGssyqNxAtywO7tFou1iTsILXTSAfvBRv4dTyJnnoVga3o/qx+m/JQbBXMUlmn3peD5s84ljjXxsH5HOyBnNHYl3ZloqJE+wBuVrbjbJGT7G8pmCI/ISVE8hLcSWxUDJEeCiipBwDk9fuqPmAWTiqfn8kj8F213u3h+5SM2f9ssZ+5hd4MHKV7h3CURlxPOROjt9ybrRaV5v5po4hmaWmMVPySut04cDF3t5EW0VGky7vx16f8VqNeQ5TvC4InBUa7t1wbP34PwmqQcsUqXZyO+zlGn87iicLzEhHvC8JNl4FuKraO/JYu3YRqtk244aTUNTizqPlUOZWWQiBaBKrqj2vuxQ3LLNrdBnCSwtBJcW+pbUywoFPLG5vqaHM3H1ZWdax31wYyey8tRJkb9nJcxQ/oUAX28vPQP7g92VqQcC2lfB1w/0i3KfKOOspTeI4Bt/y0Lxl0gi5ZhvvmNbkXlBSLsRi7m6/KM9crIVDUrHMR5XI/0Cfd7WG/VVx6L1csH1AfKrR57a9e4z9otI8Nt9c1yVIOyba/ltS4iFTg4xwPQx7OhEiyDT0Zkca2BGZD5JaSyglfsm0DYKZg+0HXEujGLEG3Q6UAgdaeiMVLwkpuH5v6yIg9qG9syeCQW0oO1Q7lVPji0iZSOsqHE6S5JzASek20f8lJ9GzNxyG6c5PTb5oVm0AxmZz578C1TZzp/WPXm5rdrjdWweehd8 5jTd+eU4 83Fx01tA+zFipJJvsS7bLUvmAOm9/yDhpgqYiodHh+P7ZRKjMwNVR3a2gnAjy/fdUvSs7uRCcC0/QUvHARuPqZZRAQRGtcmVzE1sQfENFAqEetuvduVVMgyaQXbtZs1306Rxjl7JF/L9EimqH00Vvykw7syJej75oIPukbK8FFus09G/A06JQGITIe1DNQCvOBSzo 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 six 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 34001ef9d029..054336ecab0a 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(folio), -HPAGE_PMD_NR); return; }