From patchwork Sat Nov 4 03:55:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13445393 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 88B4CC4332F for ; Sat, 4 Nov 2023 04:13:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCC378D00D1; Sat, 4 Nov 2023 00:13:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D7CA88D000C; Sat, 4 Nov 2023 00:13:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C44AF8D00D1; Sat, 4 Nov 2023 00:13:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B3F2D8D000C for ; Sat, 4 Nov 2023 00:13:09 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 82C7AB678B for ; Sat, 4 Nov 2023 04:13:09 +0000 (UTC) X-FDA: 81418951698.04.3CAD9A1 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf23.hostedemail.com (Postfix) with ESMTP id 2A75E140006 for ; Sat, 4 Nov 2023 04:13:05 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1699071187; 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=tP9NWM/ekJcLRFo0kqQKalmLDZuh2TT+P+my24sgZwk=; b=ORcecFmrnoOf14nz6iznfOecHIoSAg/NsiAEmMwHe1WIjpBZIKK9BCifsj++sVz9OrE8ZZ woxmeGNNQY4Kxhstonw2gdq2RswZvE8wppGQjASwBi3Rtfh92cRMoi0qJHaMJqbIxaEgVK /7gOnRJGBQdRzJDnoRgNntCQfRI5wmc= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699071187; a=rsa-sha256; cv=none; b=fLfL9lFaInhqW2uCIxMtjOiSZxwPi34tTKAHrCcflpk5C1ySJ8TQlERZAODlCUipmVhn1c tpT5cAYUzFRpbE7RmYv8je8NSk90xejmpA6GuvB41imy+gTwMexa338KloahxVwzHWDDqV 0Zje0S1Nc/tIPK5aTMej0nXf4hqO49I= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SMkF31wjJzPnp7; Sat, 4 Nov 2023 11:51:35 +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:42 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH v2 04/10] mm: huge_memory: use a folio in zap_huge_pmd() Date: Sat, 4 Nov 2023 11:55:16 +0800 Message-ID: <20231104035522.2418660-5-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2A75E140006 X-Stat-Signature: 7gjxffbr39m3eia7h3kfo777yfufino3 X-HE-Tag: 1699071185-724774 X-HE-Meta: U2FsdGVkX194cWX6J3A473LTFpQ0sJYcWMZeVkfH3T8dx+yxDiU4wnIhy9XRFeIQYRUXuzlNOE/Xi73S7pJgAcDZWY7Wxsqfg/BsH06JVrCg4IfwOG7QPehg1ZghYgs9RYgoSX+TvZzPl1gwfqRY0fdlZOi7RohL43Wvxek/eFmxVzUwXs1RDcjrTyQuDkXo+lwlLPWf/ROd62zlqUDmZgRpVmHXO5rN3mG3uHzMDv8NtQ7WNv8cbBR8uU1cGdeWyTaYnZpKwqRX+WxqvuFXCZGh3JPczii3fLqEZiipiles4wMEHdTQ9bcnBJPfkH4OC7YGYXxIwhYE9jAupk63aFWjkY+X/wbkesMSWUxaqDRg4Ewwlt4TDFHoEWV/sIZKjcnU5IEEI5oXMMI41+2j5qWOVwRxV98ejGCfuy6VGkkRvXk1onKS4npHFqNNWtqGqpRZmjDYVdKT5GdnfhsEClc8tUFQOyxJsOqRO+4ao4ThzQ3T5kZY3Zh5FFIQVr+bKhsXQblvzgfFQVjw9UQEcLJJ/Zqsfbf0TRCbzH5u+rJvcCUkBu/W098Bo5bxKfkIFyycvl3bDNOHfVch6i8yQKTeUXKKVGm/4+r5KIme9i0MvkZjivyMlctkJPV0il23MAQmoZYq6byOpnN289rrGgDBXZlOjkTAaUDXN8cdC+8YgvlwK7jqgnsYAaGCFN5nFXTQMRBOrAfBNJQnLWA+70UIf5leDWf7KNBTMIbJU3dnrhI7FziHKENa6RYhq658K1bMhaMFenoiBgVeCrKTVkH7ehBWGgMTmeOCHVgpaQc8fpIi99RLAkoQpecaZtOtTv6zV3GqNw4rfrB+Knd1OTQLJVuIa/huJUISuqutF4rKTw9KED9s2MdBM+bWB4vMP0zxF6zUMUhUKxALtPR6NvFS/yojsx9TiIIirlaPw1jY3ki8za6wlHctr2gAgupo5dYpOLxw3yozXW3fRIM cAXB7HRm XFfZWkjdZZFznvg7lPgrHHwi6pqpZDbBXArymy00y4U5CHvM07/DQu2C7zHFdbaiSvJkNyqsuT0/wTKZaTxVcqGhsyYOI3Wbx20/FWuO3Ww/Qtgw+o4h9ojsS6i9d9KfS0IQrvZ2ogXsuZg2ImE900nWpKZVpHBp0EClVO79PWUdCqG1q4DtDVrUbcIVpqiGQR7+A 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 zap_huge_pmd(), which is a preparetion for converting mm counter functions to take a folio. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 34dd01970927..78a00fe22c2d 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1716,11 +1716,13 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, zap_deposited_table(tlb->mm, pmd); spin_unlock(ptl); } else { - struct page *page = NULL; + struct folio *folio = NULL; int flush_needed = 1; if (pmd_present(orig_pmd)) { - page = pmd_page(orig_pmd); + struct page *page = pmd_page(orig_pmd); + + folio = page_folio(page); page_remove_rmap(page, vma, true); VM_BUG_ON_PAGE(page_mapcount(page) < 0, page); VM_BUG_ON_PAGE(!PageHead(page), page); @@ -1729,12 +1731,12 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, VM_BUG_ON(!is_pmd_migration_entry(orig_pmd)); entry = pmd_to_swp_entry(orig_pmd); - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_to_folio(entry); flush_needed = 0; } else WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!"); - if (PageAnon(page)) { + if (folio_test_anon(folio)) { zap_deposited_table(tlb->mm, pmd); add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR); } else { @@ -1745,7 +1747,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, spin_unlock(ptl); if (flush_needed) - tlb_remove_page_size(tlb, page, HPAGE_PMD_SIZE); + tlb_remove_page_size(tlb, &folio->page, HPAGE_PMD_SIZE); } return 1; }