From patchwork Wed Apr 24 19:19:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13642431 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 7B565C10F15 for ; Wed, 24 Apr 2024 19:19:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A2A0C6B02E2; Wed, 24 Apr 2024 15:19:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9DBA76B02E4; Wed, 24 Apr 2024 15:19:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 792B66B02E6; Wed, 24 Apr 2024 15:19:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 51D0F6B02E2 for ; Wed, 24 Apr 2024 15:19:28 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 19BDC14035E for ; Wed, 24 Apr 2024 19:19:28 +0000 (UTC) X-FDA: 82045389216.21.15EDE4D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP id 767ED18001F for ; Wed, 24 Apr 2024 19:19:26 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=nDeH++aC; dmarc=none; spf=none (imf16.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713986366; 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=nsHnbes68x8DGbgJ42X4Y2yPCDwaxQ838mkvU2xkcMQ=; b=rvp5/El+pyfvrxIuM2YQ7bVEb4nRHsSgb88urvCJFwqTuR/VdjeKdy9XOoU0a1S4dncWBb Jp4g6itnoTK9U8URrNwHQ0fd7hfvcCWdpPYELjl1+K4tBtPtIhr4NTP0r5xlmo0qg3dq9O huhXcoTAQ+3EtPRO/+ZkLf7TKtM9vj4= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=nDeH++aC; dmarc=none; spf=none (imf16.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713986366; a=rsa-sha256; cv=none; b=jjt6WZ4E77ok8WzCa9ho09/bW0l9Xt/DIDAR1IOwEAyqspTYsFdRiPiZO2dkiHpRRi/4Za Y3qkELY8qycdDfnxy0PCV2FscZyx+o3t4qTG72k94UrcKIGIvnTShRwleLHtEg7SYKEqi4 glwpf680m1lkunRdCGz6QIZV+rPex+I= 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=nsHnbes68x8DGbgJ42X4Y2yPCDwaxQ838mkvU2xkcMQ=; b=nDeH++aCJR/1ErRdvrZYIcNEzK e9CSCfAgcGXvWTTVT3QYzmb/jCHgvmr9oCd3dJeoPupkpYu29yte0R0IICCRmFsZMwkMp99Lu1JRc jka1pMAO7s2Ol08ppFok5wAva5eB2LN9u/J2RyXfpGFV+gXctSeNhnLU6dtrXvPnKf0YouPaIYyaG r51Wo//cSpa1pYohmksP+ruYHf5/Ruu5KkTbmymPr16q+UYcz3ShmXINEoVRbyJGh3UEk/8CexDCI vgFf7uuz/kMquYyy4T5h3tMvUmvMxIyS+ReZbALz6z+ayNf/bCchHTkpRxCFHGpZH9u+0vs0qrxIn O9sc69Rg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzi9E-00000001W3r-0cLB; Wed, 24 Apr 2024 19:19:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 3/7] mm: Convert put_devmap_managed_page_refs() to put_devmap_managed_folio_refs() Date: Wed, 24 Apr 2024 20:19:08 +0100 Message-ID: <20240424191914.361554-4-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240424191914.361554-1-willy@infradead.org> References: <20240424191914.361554-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 767ED18001F X-Stat-Signature: 7onek9gs57y7gwh3837b67j9bwin5ana X-HE-Tag: 1713986366-401315 X-HE-Meta: U2FsdGVkX1+xBqjOJrS8Mtczn7G5B6is3vaJ/7CTIr40UM1VQztTuMNXiJLk0LiYzBBLp2hbw+CdFgQPskiFDaHQXC9MX7ptb50uofpv596p7ki0K4Kb/roD8s5yPsxikTpWDedB8giF73SunGNwxGbSRSvmPqQr3mBQ04KvbchdRkvAm0hBzEDyccpLwQ+rFoJMWChTadauCvZtArPzC6KKZAIW6TmuMG3oBQ0oNccAhhmNZbW+1VVuBGuN7wmFX6OVDUbagw/Si7quAn5CA87oSomlz/GPWlgIu58GB6kaQsYzYr774mQillMel1ii8v5IMUVCepcagaBEY7+owAhK+bvZIvL1xwnocYkflI3SSIM3V2l3P7YM68pkHdfjAMI8TLzr14QsekOarHcQcf8St5W7kSz26+pwN+d8M8KBDe/RJOFoPJ0xIdICMFP4pimO8sIH/1zOFBeX3qYtIK4LXkHSFQYysOiiyQMLoWRJOPp1dw+Z2s9EtQrp2x4F2OhrjAblkfGGlc6Figf7TKmEMFZ00pHat3Hf53jRQGBupMoMpFlD5fjcwvYk5amvsK9VIw0fpgv/EAyX9qnA01M8WZEaSvpjrM3uUDLW+LCVyTYXxCaNjVD7Ls7oQrzkywl+bS5xLobCoI6HVamlw3NLcxwlhZuUZNs8zusOy8UF5H4pjgt/waHlUIpVWgrN5M6C1jVyF0Vs/OLsZpoUyRLhSWNrFp09gBXcWR7BETHS1EOtqd0rfbp7Ouom2eF/uHTJyBoxRbzTxnkLrkygc1kGWQuyO20+UPKzP9yJVNO98jFCLTvyWuIeCOszzEk9pvtp6uYHlb6woEZLbq/OofP8lvJZHM45s6zfV2BxYPjNMPjEKPVWnTkU/SEw0CoQNFSCvzhI4K2/PVamqjabheQ1xP1s2cN5J3l1YL1eyl+r1qSqfd0i3OTgwL/yLzIn40pYwQyihSGe5viFfUK 7f4UQrRW IGU85uwpSf+zT0CEIZyrnd1Huo5cof9uaZR+7EbihREsgO6tztjKUARUsg/S4UT2e4F6bCprZvco44UE02fzsz0cXHyLMedCt/tNYA09/hOu3ez4H0QqrCOsECdJUjYhWRhYknfM1EblhatuQjP7L3fu5bptVUjKjYqIJUzmHSsNqNFOE1lRAq8F07XOTPChldRUpiFt25NgseAvzEzO6gsaMMvdACxru/axm 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: All callers have a folio so we can remove this use of page_ref_sub_return(). Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 12 ++++++------ mm/gup.c | 6 +++--- mm/memremap.c | 10 +++++----- mm/swap.c | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 070a6e2d7222..19d0ec4f43f4 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1437,17 +1437,17 @@ vm_fault_t finish_fault(struct vm_fault *vmf); #if defined(CONFIG_ZONE_DEVICE) && defined(CONFIG_FS_DAX) DECLARE_STATIC_KEY_FALSE(devmap_managed_key); -bool __put_devmap_managed_page_refs(struct page *page, int refs); -static inline bool put_devmap_managed_page_refs(struct page *page, int refs) +bool __put_devmap_managed_folio_refs(struct folio *folio, int refs); +static inline bool put_devmap_managed_folio_refs(struct folio *folio, int refs) { if (!static_branch_unlikely(&devmap_managed_key)) return false; - if (!is_zone_device_page(page)) + if (!folio_is_zone_device(folio)) return false; - return __put_devmap_managed_page_refs(page, refs); + return __put_devmap_managed_folio_refs(folio, refs); } #else /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ -static inline bool put_devmap_managed_page_refs(struct page *page, int refs) +static inline bool put_devmap_managed_folio_refs(struct folio *folio, int refs) { return false; } @@ -1571,7 +1571,7 @@ static inline void put_page(struct page *page) * For some devmap managed pages we need to catch refcount transition * from 2 to 1: */ - if (put_devmap_managed_page_refs(&folio->page, 1)) + if (put_devmap_managed_folio_refs(folio, 1)) return; folio_put(folio); } diff --git a/mm/gup.c b/mm/gup.c index b797424f78ef..49376f756936 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -89,7 +89,7 @@ static inline struct folio *try_get_folio(struct page *page, int refs) * belongs to this folio. */ if (unlikely(page_folio(page) != folio)) { - if (!put_devmap_managed_page_refs(&folio->page, refs)) + if (!put_devmap_managed_folio_refs(folio, refs)) folio_put_refs(folio, refs); goto retry; } @@ -156,7 +156,7 @@ struct folio *try_grab_folio(struct page *page, int refs, unsigned int flags) */ if (unlikely((flags & FOLL_LONGTERM) && !folio_is_longterm_pinnable(folio))) { - if (!put_devmap_managed_page_refs(&folio->page, refs)) + if (!put_devmap_managed_folio_refs(folio, refs)) folio_put_refs(folio, refs); return NULL; } @@ -198,7 +198,7 @@ static void gup_put_folio(struct folio *folio, int refs, unsigned int flags) refs *= GUP_PIN_COUNTING_BIAS; } - if (!put_devmap_managed_page_refs(&folio->page, refs)) + if (!put_devmap_managed_folio_refs(folio, refs)) folio_put_refs(folio, refs); } diff --git a/mm/memremap.c b/mm/memremap.c index e1776693e2ea..40d4547ce514 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -512,9 +512,9 @@ void zone_device_page_init(struct page *page) EXPORT_SYMBOL_GPL(zone_device_page_init); #ifdef CONFIG_FS_DAX -bool __put_devmap_managed_page_refs(struct page *page, int refs) +bool __put_devmap_managed_folio_refs(struct folio *folio, int refs) { - if (page->pgmap->type != MEMORY_DEVICE_FS_DAX) + if (folio->page.pgmap->type != MEMORY_DEVICE_FS_DAX) return false; /* @@ -522,9 +522,9 @@ bool __put_devmap_managed_page_refs(struct page *page, int refs) * refcount is 1, then the page is free and the refcount is * stable because nobody holds a reference on the page. */ - if (page_ref_sub_return(page, refs) == 1) - wake_up_var(&page->_refcount); + if (folio_ref_sub_return(folio, refs) == 1) + wake_up_var(&folio->_refcount); return true; } -EXPORT_SYMBOL(__put_devmap_managed_page_refs); +EXPORT_SYMBOL(__put_devmap_managed_folio_refs); #endif /* CONFIG_FS_DAX */ diff --git a/mm/swap.c b/mm/swap.c index f0d478eee292..f29b3018ba3a 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -981,7 +981,7 @@ void folios_put_refs(struct folio_batch *folios, unsigned int *refs) unlock_page_lruvec_irqrestore(lruvec, flags); lruvec = NULL; } - if (put_devmap_managed_page_refs(&folio->page, nr_refs)) + if (put_devmap_managed_folio_refs(folio, nr_refs)) continue; if (folio_ref_sub_and_test(folio, nr_refs)) free_zone_device_folio(folio);