From patchwork Thu Jan 11 15:24:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13517540 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 7603DC47258 for ; Thu, 11 Jan 2024 15:24:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAC8A6B0078; Thu, 11 Jan 2024 10:24:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A0B5D6B0096; Thu, 11 Jan 2024 10:24:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F9126B0098; Thu, 11 Jan 2024 10:24:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 81E536B0078 for ; Thu, 11 Jan 2024 10:24:50 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2B1D21602D3 for ; Thu, 11 Jan 2024 15:24:50 +0000 (UTC) X-FDA: 81667402740.16.FD788FD Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id 7C8DD16001B for ; Thu, 11 Jan 2024 15:24:48 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Qm71Yl2Z; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704986688; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CYYNkRTkd5xFX+VO5m2RjKXg1OSKu23U+VpXCiMR+DM=; b=I3jyw8s6Ycu/Ef1bVOIlW0BqNOHe0yQfY9VjWqM1c14sZbsuSxE+LSa1bdKJYQCO5udVwI 1NIEAacXwR8XE3rm8KzEgK1986C5hZFUV6uo+5/ixcKGzIrX5zFLStCUg6p8PLnjBk2yQ6 G02Dma6tKFcyG5T17GZHi35DvV/jlzI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704986688; a=rsa-sha256; cv=none; b=3u9w7mthSASOHBIyay3xIpXEn4NPmTA/vf9eyH5lVBYkM5hBxE+VJ3YSRS99SQhhqhLqN1 GEMh1w9EZzn3NfB8r3V9SeM5Kjud75JBv0z396Vwlf8FNV5yXzJpts36sIXs26rtTdYwF0 S2anz41aJIsQFXPMBant2kdLIf67OJU= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Qm71Yl2Z; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=CYYNkRTkd5xFX+VO5m2RjKXg1OSKu23U+VpXCiMR+DM=; b=Qm71Yl2ZL/hcUySturjDZKEqdM adPr7hRDRWEHj7lVE8ojtLUXWNtQuqjHlBJ2V1pGGZdU+ng9ARBTkBXMV76ySBdmtqCn0XYdmt68C xIQK3qM6KGSn+gDo/Ik1NUEorTGya3HIKcrc1uZJjCcsFft3nMBZDlatvvYDX0ztPJtphXgGpB41g JY/4olr8OI2etKVxeqdWRstBtP90bIh6YXJJOKy92bHFLBvB3bD5sF/7AIUAlf3szLm3TnhhAKas0 sae8WGxzk9LizWHosQfkXTG765y5ozq/NxWX8pza5AJiRcLj9uPi/4aOPA3zeTEDsq5xyfbfxsvw7 fVZbFYTA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNwv1-00E9sq-Nj; Thu, 11 Jan 2024 15:24:31 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: Kefeng Wang , linux-mm@kvack.org, david@redhat.com, linux-s390@vger.kernel.org, Matthew Wilcox Subject: [PATCH v3 06/10] mm: use pfn_swap_entry_to_folio() in zap_huge_pmd() Date: Thu, 11 Jan 2024 15:24:25 +0000 Message-Id: <20240111152429.3374566-7-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240111152429.3374566-1-willy@infradead.org> References: <20240111152429.3374566-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7C8DD16001B X-Rspam-User: X-Stat-Signature: worjbbq4sdhdpmms9emrkrfjzs4dr4ya X-Rspamd-Server: rspam03 X-HE-Tag: 1704986688-776135 X-HE-Meta: U2FsdGVkX1/l6gmMRRpvmMwcIrsMFfNF3zy0skfvF7Dj8DEWvBkwR0SlxIQSL/dNN2dsE96X28EBxXDrKYZFnbifcEavWeNSnCKCaPD72zzOi7dqq8Cv9gAgcGBgossvgG8dKeh/usJO3qpORQ/NcxpHpvCXelBgSk6CnQVCmUeiZBPHLb8cnQCa2BiA7hP6m0MvY3gFSgoA/xemJRKYE/w6GC4oV0cmce3fWqdKriiPpTLPyyeCPBCWn5qKmZi7n5v2+91VzPXmhQiJKnayouhJqhrZ8mHKGqwFH5xpBJFuO4D+nQf0St8Eye4BmZhHh1jBnE/4Zbv4qLyxBvvoRYm1XJqSdcGSVrudIWoWKWJ/oaNZY/36NMRuyXFfU7t2GUjm+keTwcwlCo3JUc8dHSqQABmUqViEBpkCFMCVVvAalkKvtVw9cagvRyg+9KBYuVUfWf1lx00ye/L4ucM/PviCQ5FnspzHxXvn6e0bgKU3E6eXw7P0VxlHPzxcUTgTpdc5RkL/XT1cE0Em6YF0+oLhkDmmvVX8upjVRaxqTG8QhGbDsskFV8WQP43aCFlClf9m/N/M3vm7gQez0w8JEO/FDBxuo5kvIKCjqLWQkMEmhLVvtaF4divUKdrb+YpfvFKoX4tP9ByUguhlJ5a3QXCi6qyMzIMJtclR9soE3yIpiQ9ADkhd7poZGtIfDGk4ywzrf/qgZA1nheWZ1OyScwQPApff5EIBgcYyEOpiEO7nmXGDGfcuCOiI/c53PQJR3+pWC6bSZtcmM41nL/VWGJBk22EVo0feBK87y+FluFNVSzVIu+SBEF7UQyquvteoIKV5h6xZGilI6fwVb1XiIgdtfbtvMijviBXi69U153pYew0t3bOXUL4gqCz97mpAC2fAiBV30HOCcGrbq5Vtn7rD15kxd+Oa6lqqz9rvgGRxab4fuyAz/65W+xPV4BJ6m6JfLBXVhEakOw6YkfR KkTSqToE hgHqoOZz+K+oybd67VJSzzcC6DO41cOUx1y6UyIkBxkmXZeLePt/9SzwL9zzJoRHPvFkDPP0eGMpSxWlwphh7TA4jecCxKgBYLLy+ZLKB3f7snIeYzsRjgHKxuFrF7buCG/Xe5oYnQLqYnlmOGb2UvzzPdVA6K80EKu7rhr0OXjOeWGKtUx1VQ8rhxFHFitSCf4RZ+Ie+0SBss9en7GPcqhg9BroWpa1icgsWlGGsHqK5gPZ+Izc07oPB7g== 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: From: Kefeng Wang Call pfn_swap_entry_to_folio() in zap_huge_pmd() as preparation for converting mm counter functions to take a folio. Saves a call to compound_head() embedded inside PageAnon(). Signed-off-by: Kefeng Wang Signed-off-by: Matthew Wilcox (Oracle) --- 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 4ad1416b60e3..4a17306c7dda 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_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; }