Skip to content

Commit e5cb232

Browse files
apopple-nvidiaakpm00
authored andcommitted
mm/gup: don't allow FOLL_LONGTERM pinning of FS DAX pages
Longterm pinning of FS DAX pages should already be disallowed by various pXX_devmap checks. However a future change will cause these checks to be invalid for FS DAX pages so make folio_is_longterm_pinnable() return false for FS DAX pages. Link: https://lkml.kernel.org/r/250a31876704b79f7c65b159f3c835e547f052df.1740713401.git-series.apopple@nvidia.com Signed-off-by: Alistair Popple <apopple@nvidia.com> Reviewed-by: John Hubbard <jhubbard@nvidia.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Acked-by: David Hildenbrand <david@redhat.com> Tested-by: Alison Schofield <alison.schofield@intel.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Asahi Lina <lina@asahilina.net> Cc: Balbir Singh <balbirs@nvidia.com> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Chunyan Zhang <zhang.lyra@gmail.com> Cc: "Darrick J. Wong" <djwong@kernel.org> Cc: Dave Chinner <david@fromorbit.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Dave Jiang <dave.jiang@intel.com> Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ira Weiny <ira.weiny@intel.com> Cc: Jan Kara <jack@suse.cz> Cc: Jason Gunthorpe <jgg@nvidia.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: linmiaohe <linmiaohe@huawei.com> Cc: Logan Gunthorpe <logang@deltatee.com> Cc: Matthew Wilcow (Oracle) <willy@infradead.org> Cc: Michael "Camp Drill Sergeant" Ellerman <mpe@ellerman.id.au> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Peter Xu <peterx@redhat.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Ted Ts'o <tytso@mit.edu> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Vishal Verma <vishal.l.verma@intel.com> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: WANG Xuerui <kernel@xen0n.name> Cc: Will Deacon <will@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 6c88f72 commit e5cb232

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/linux/memremap.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,17 @@ static inline bool folio_is_device_coherent(const struct folio *folio)
187187
return is_device_coherent_page(&folio->page);
188188
}
189189

190+
static inline bool is_fsdax_page(const struct page *page)
191+
{
192+
return is_zone_device_page(page) &&
193+
page_pgmap(page)->type == MEMORY_DEVICE_FS_DAX;
194+
}
195+
196+
static inline bool folio_is_fsdax(const struct folio *folio)
197+
{
198+
return is_fsdax_page(&folio->page);
199+
}
200+
190201
#ifdef CONFIG_ZONE_DEVICE
191202
void zone_device_page_init(struct page *page);
192203
void *memremap_pages(struct dev_pagemap *pgmap, int nid);

include/linux/mm.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,6 +2115,13 @@ static inline bool folio_is_longterm_pinnable(struct folio *folio)
21152115
if (folio_is_device_coherent(folio))
21162116
return false;
21172117

2118+
/*
2119+
* Filesystems can only tolerate transient delays to truncate and
2120+
* hole-punch operations
2121+
*/
2122+
if (folio_is_fsdax(folio))
2123+
return false;
2124+
21182125
/* Otherwise, non-movable zone folios can be pinned. */
21192126
return !folio_is_zone_movable(folio);
21202127

0 commit comments

Comments
 (0)