From patchwork Thu Jan 11 11:12:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13517211 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 E0F27C47DA2 for ; Thu, 11 Jan 2024 11:13:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEA7C6B0095; Thu, 11 Jan 2024 06:13:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B997F6B0096; Thu, 11 Jan 2024 06:13:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A88B86B0098; Thu, 11 Jan 2024 06:13:38 -0500 (EST) 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 968036B0095 for ; Thu, 11 Jan 2024 06:13:38 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 65145120B65 for ; Thu, 11 Jan 2024 11:13:38 +0000 (UTC) X-FDA: 81666769716.12.0FAF372 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf10.hostedemail.com (Postfix) with ESMTP id EFDC3C0006 for ; Thu, 11 Jan 2024 11:13:35 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 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=1704971616; 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=PGFFs+EsAYRIrfI1UJ/CXRS3kHNblZGP94QrpCixO9Y=; b=DhvAYro07QrWkdgh37jiRvvzKM/Aecn3HUD5WcZHWwCCwQsV4BRRwnr/hnLA8yLKGV8Tct SyZZfF0ZhGiuv3Uvdg2HJ8M86AQAQB3jKCsy8LH02fT364h0ffhMrM6TWkZpXmp3Nb6f6p KvTqXEl4xGEUhpPNwp0BYJUqqIZJ31A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704971616; a=rsa-sha256; cv=none; b=ej3K9zHEx1RmEwPL1/SKnpgKB3E/9S1l4zDbZIZHkYbThWIlZLVGMB7xtmAF05xBZGJRWI xDFZSP3nfxk/ZQ4TL/ce7qYezfzE+l3RjuUWX7Kkl91jRKbkhnnQvSR56e69rbfj5WFR2H OWgMd45AJCYiXQ1BFm1EkZVs5IJXP3Y= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4T9hqH5C5vz1wn3P; Thu, 11 Jan 2024 19:13:15 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 368751400E8; Thu, 11 Jan 2024 19:13:32 +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.35; Thu, 11 Jan 2024 19:13:31 +0800 From: Kefeng Wang To: Andrew Morton , CC: , , , , Kefeng Wang Subject: [PATCH v2 4/8] mm: huge_memory: use pfn_swap_entry_to_folio() in zap_huge_pmd() Date: Thu, 11 Jan 2024 19:12:35 +0800 Message-ID: <20240111111239.2453282-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> References: <20240111111239.2453282-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-Stat-Signature: 6ug4hk3cdtu1ntqfmejr8miqj1ehmhe6 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: EFDC3C0006 X-Rspam-User: X-HE-Tag: 1704971615-811722 X-HE-Meta: U2FsdGVkX1+JeBfSGDYNYsRgCdZT2bJI4HT8NaGH+66F+5mUmq0pYQsY//z+zHyX3XmxNeeasyf7ZofeS1T86ZEOu8ELpkm35zo6z1dGDn93NEY4lViIinZO28u5+wOwUw5yitWJXMIDy6NM5cvWSU9X1FU141bu8O0PYhyxrk26K6SiD/0Gno2Srg2ghGnNDKfyn6fZPCl78J7jug9BJDzbRNCndnWJlUtU4kNO4e4YKOlgrAkcy4epOuSTGJELbD+LDGnCE4XTVZS+MmmFnfzfv5udARRygw9X9LAO6GTierMEO6pxEAAqsn6TU9OlCUb+3uNGYgAUR6seBD50/I4o4gpu6IYTVzLMOVgBfJPkdnLkiRbXuBcC1hO8S4hPNPvDYmttzbDR42SO1mQLdQN5Tp4aJL1SActspK7akEcp9S1tiiiP945Lr03ieRnYQyx0Xb0mrzle9IF9W291xRUUvAZJeAEcwql3rOXFPVAaV13qHtv3xEXK4seYifUIz4ponqYgfioQRu6ygBqlCyFSa1BdOKv0/KQiXdI9A3EFxjg7LLTnprEMXzzfGeDN3+8fotDUDFAq0tDVql2LQkrgdQfM245795l1VfhsM5nc59Nk3Zo2YvYIIXz513kSW3cY2CpfJJbueezcOLM3XQcXRX0IcixHPQZw/8GgRd3nqwn+1XKpky06ka/7lQ7qpbhbWuf/We0OQcJJYtZL+GjndDj/VdM5XgtyQdpv9nbXhHUYyfUC7ElYHb6s6jxyR2Z+7jvBDJlmK/TSj5q6vCox0mbY4ko9rY0IZoHeZm5vlgwDTBQlvUyi8v9ak4u7PecUutmFa5o2DwniwDJXx8NvpDoTFOOXxYozFs0a8x3W1mNMEwHV1QwmH/1cUfZIbiLO/79qYYGfo+brK++ewb3XAtwsYAhTw9IFpHLW+tzkZ0v5aEz29Gk5XsGojTcC/YClvZtek4krYCNb/Fb tzeacu9N wv7rcdNefWDTMTb4wKpVjbrANqBVLVaCK0Op433sQva4/g2ddwqEhyI8yQGB4pj7v7ttS6cQH7d5KAqOETgIK3G2GMVdZHOu1DCP1kJ23oB1ec82mBj2rGZETMPTKnckqRq6Ok4gkYFZiA48NW6SPhyrwmMeKtAuw9aXBibQL6+OIbKENdcQRbK6GKqu/u2MBFPOR 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: Using pfn_swap_entry_to_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 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 6139887933a7..b024edb55855 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1895,12 +1895,14 @@ 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); - folio_remove_rmap_pmd(page_folio(page), page, vma); + struct page *page = pmd_page(orig_pmd); + + folio = page_folio(page); + folio_remove_rmap_pmd(folio, page, vma); VM_BUG_ON_PAGE(page_mapcount(page) < 0, page); VM_BUG_ON_PAGE(!PageHead(page), page); } else if (thp_migration_supported()) { @@ -1908,23 +1910,24 @@ 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 { if (arch_needs_pgtable_deposit()) zap_deposited_table(tlb->mm, pmd); - add_mm_counter(tlb->mm, mm_counter_file(page), -HPAGE_PMD_NR); + add_mm_counter(tlb->mm, mm_counter_file(&folio->page), + -HPAGE_PMD_NR); } 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; }