From patchwork Sat Nov 4 03:55:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13445383 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 D25F3C4332F for ; Sat, 4 Nov 2023 03:55:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 005628D00D1; Fri, 3 Nov 2023 23:55:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF7678D000C; Fri, 3 Nov 2023 23:55:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE6728D00D1; Fri, 3 Nov 2023 23:55:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CB44E8D000C for ; Fri, 3 Nov 2023 23:55:50 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9DF75B524B for ; Sat, 4 Nov 2023 03:55:50 +0000 (UTC) X-FDA: 81418908060.25.BE7D89E Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf04.hostedemail.com (Postfix) with ESMTP id 545C140009 for ; Sat, 4 Nov 2023 03:55:46 +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.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=1699070148; 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=xFarMEVqB0HfxqyARCY+Qb+xGTjUpb4IF5GYnmqL3lLs+ZiXjsx2v0LQPNgXnhJ0T9wjBd qBb0fiKDaZfKQ7UwB7Mbfk+mQd+Z5lKBzG7dza5czbOtx+WrwWRdYnJYgO5vad3b12odn7 RHofB9cijYv/QpZyyzE9xYXxbpAtIBw= 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.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699070148; a=rsa-sha256; cv=none; b=SwSBtENoH1RXnynhtm59D25qZc6hU5WAsrZ1WajY0DUuwtX+6OijifphfnwzU51o3bMc3Y 1W5ocWUU00FmOYSCs8ifPdis6vbApVNpTEt8mHEhc4Kp0XLlsannyex6SDtYoUjTMULSiG 2hyL7DUT8nQnJw0rehXEIVjBtC4iy5Q= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SMkGD3sw9zrTX9; Sat, 4 Nov 2023 11:52:36 +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; Sat, 4 Nov 2023 11:55:41 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH v2 03/10] mm: huge_memory: use a folio in __split_huge_pmd_locked() Date: Sat, 4 Nov 2023 11:55:15 +0800 Message-ID: <20231104035522.2418660-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> References: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 545C140009 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 1pqg4pttou7799ejtyyg7txkuzom931w X-HE-Tag: 1699070146-365706 X-HE-Meta: U2FsdGVkX1+OarVvlc/HMHrW/sg3FtY/Ufvw/VzbHJnx03J4BzV4ux3mN7wLP+ZVeXIn5INdyOx4Izot+JF6pXzEcPBf42nGafZuWMck6MIt0GQ04ciBZ36i6A8zUnV3sMV3GbiEbAJRDQYXY93yRzZ8t2CuDkP4ofsIIhiCiMXnov8297j7lXtN7QErVg+01sjjET8M3WDtyFdPdR+n8vhBItlKZECsGKG84bhNs+gwcoYqaQxmyL3Z83hCy5h1+T8PO0X6B+RNm3sboDcWP5PyLuziP5lkt4fdw580Hfksk1Cuv9m2y3lJdy+QoN+kIZkEOt2PnUU73OEi84v51uCKUAHAh/sx3agqu56Ph8t1sSGpoH4qezKM3yGWuzJIgs8xdwq8UdLon2oNncb4Qq7eAqiTRDYkwBpSeBKrrXWE2ONdfkurGjqkxHp/MBylOPAuyuZuJh51NSnC8WS866rwxYp+sCak/mLRVhYg79WmG9sULLbs6aNFQJTxnh53JSon6/BJdKSdXYBJT/tqNloW97Q4wgGgH82Q+MkHZz9jvYL3Tov5cDkpE1vvLe573RhZVO6ywyaT+g7sx7z3hwwuduhetufZ4yE76tSnMRUOoxjSMqi7p8nby4/Nmn7d+LjVU6Df/I1Ryld/UCFLVuHy3OC3kj8bGAMJS+VNYsBRracqUPmInBrS/MS73hI/JzjaRxNwa0ul5Ye3eI5F1jP4JfyvaR/b9uiXoyqDRYnmuXa2lYTDNr24rqxjTbTR0CcqFMB2JX0PPguCd7IaPnI861F0Unxsja58GpGQGyHmYeRhMYEXgFfWT8ESldgpEG6Q0I2wFzxATQktOsxA91YAh42CGnkblYPWfPychemsWZ3Zew69R4LSirOJwEMj+AC1QLq3Rywi0lhvA+d6KQHKTWQW2JIJzHONIc9TDEgoQWovcq4l99ZMWpJ+2j6v/Wl3OvZJDw/+8ajUYmy OHEa0wWT /rHjxa1cDj/QF8vur+PsiPt2Clzeo+xLcAX0I5YdO+ljVzADUxydqh21oBHGWiwRpFQ8zspm3tubHhxzV5Ehs/dr4g6/cAPn81AMHYARRpkEmn6T4b9MHNLG6gFqfLKrlM4/uYrEbQEsmuj72iMDUJdGsJDPtgWhWccr74ItCmNyFSc8XjoFw+KNPoLjY5C0to5mI 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; }