From patchwork Mon Nov 6 15:49:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13447143 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 BC853C4332F for ; Mon, 6 Nov 2023 15:50:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 973D48E0003; Mon, 6 Nov 2023 10:50:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D5788E0001; Mon, 6 Nov 2023 10:50:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74D1C8E0003; Mon, 6 Nov 2023 10:50:23 -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 654978E0001 for ; Mon, 6 Nov 2023 10:50:23 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3F15CB57FF for ; Mon, 6 Nov 2023 15:50:23 +0000 (UTC) X-FDA: 81427966326.28.1A05F98 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf07.hostedemail.com (Postfix) with ESMTP id B04DB4000C for ; Mon, 6 Nov 2023 15:50:20 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.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=1699285821; 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=DWqe1/6NZd2Xu1FxvaIV2sC0K21Q4RJLonJIAf7badBhjUMFS2ZucqrVmo5dGLEnZ+fvB/ GG+hML9RLZP8L59FI0x+TZddOap+xG+4XgZpJDNyaWrtPgRKP/OgEVxsWraaIa1eWmIjzj ljYsRA4AVpBT+COpDjTcPMpepUoLZYw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.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=1699285821; a=rsa-sha256; cv=none; b=qsKyoYwegf9rk6BNEpG11z1oLjeOdeOgfaK+ePt7FrzzgtbSDp+kw92DwmLEImhCoz8cFo Od714Sjcsk1R9fggyXqQqSBEFKFugbao9zznhU6Jnyoj4GMJrGdk3zTdl9G0iIBnuqHTcC wI+meHAQDuHu5KPzlIip1RjhXJ/od/0= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SPG4x5P3BzvQTB; Mon, 6 Nov 2023 23:49:53 +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:50:00 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 04/10] mm: huge_memory: use a folio in zap_huge_pmd() Date: Mon, 6 Nov 2023 23:49:44 +0800 Message-ID: <20231106154950.3399469-5-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-Queue-Id: B04DB4000C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 7iyqy79z84ykwnxmbujdn31tgbshshqp X-HE-Tag: 1699285820-304369 X-HE-Meta: U2FsdGVkX1+N7wyYLyurc4PsUP+NvAAuMCDND4n1NbD6RbPaFZSe9WodjOcemnAuJaw++ZJAmJLWiZkY+47rWcvgWFt3jPLbAA6K2xeCRKzGOR2vuLXYDEZMnJKH9WzuPqbn3/ox11puVRr64CIIqaWyqsIoTZ9WW1Fj28r+mSzXfBnBsRG4ZAByJKq/cGGcr6uFzfR7W9jVBFmb5rlOoRVBrkW608wsAb5LLpDDtR8mipoLUYJWDYW2bpVe3bpMElm/jm5H7ZFlFaT8fwCmxFrv3dH2Z3/56/KqE+NA71hM06LmvJsV1VEuJy286qGehJNFcPX/CSrgZvW+z4OZyFGHHMe+p7pj7+5MsVLy2gpOSnCXD6x6daKitE/x1T/MFKJvA7ht2LdOgBx0QNY3FOKCkvGD3QxpI15kB7c2tJeeXYMOLWlP/wYmaijhghv+FQej8EoQnsuNLW2yuyRX6PhN28nvXPN4kPMRIywl7zlcr00woDi1s8Enwfi8AYc/zYPKLAzVOyCOBHKKhTSQZ5qA5yT23vY1QbLIgQpsM/HRIu4TctiBKWWWrZSj5UXhxb++a4it+ojTxmmeebaDbTZ4TEZA3kdWUTjOIX1e/94dMUV5/9jBNkKrYidE6NiV5INJGC6ppw1v170BLtjpzuHfRvKQuKlegUphC0GjhQHZO8PFgVibtyYdse/f5V2/pJgXwt3SvQOMRuKkOvwkIf9Y+V/dhNOvnGf9/90Rw8kuMEMaHkU7rEKC60ZvUyhrX+55O0Puao7JPN8qZ79oqBk31klfcK+r8zfGCjfYH2M4D3HvvZ3I028DWDW8dMHZLjGch9famJbZxqrPjeLd3QYOtBChDQnj4JuRdtTMnEvbYBj/Wo4jBxuLkJdBHFfbXDC+/BER+ZRYQCqPsbomfSYWnXTwiQNvWBBkCeuUSxB+dTGY7S9rXwLI0PVRefVbUDEE9sEPkf4MFvbBq52 uSflSnrA mfLJXL6pU+rucml4KetSeTB0F3335b0Muv9AkRDFFX4Tc6tQWvApdUaohykmJYKVLReEMQzsSmlFre+LpBzB8ACFij+TMtweNjjZPR/sdf0PXCoVZEhuDKsVJH97HuFtvZC0qpAkA1spKEOlJ4jGI0o9dBEpUWZmZQl71DRN6gPsDJl0URjCJpnetHeHkNEPyhrXn 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; }