Skip to content

Commit fcab34b

Browse files
awilliamakpm00
authored andcommitted
mm: re-allow pinning of zero pfns (again)
The below referenced commit makes the same error as 1c56343 ("mm: fix is_pinnable_page against a cma page"), re-interpreting the logic to exclude pinning of the zero page, which breaks device assignment with vfio. To avoid further subtle mistakes, split the logic into discrete tests. [akpm@linux-foundation.org: simplify comment, per John] Link: https://lkml.kernel.org/r/166015037385.760108.16881097713975517242.stgit@omen Link: https://lore.kernel.org/all/165490039431.944052.12458624139225785964.stgit@omen Fixes: f25cbb7 ("mm: add zone device coherent type memory support") Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Suggested-by: Matthew Wilcox <willy@infradead.org> Suggested-by: Felix Kuehling <felix.kuehling@amd.com> Tested-by: Slawomir Laba <slawomirx.laba@intel.com> Reviewed-by: John Hubbard <jhubbard@nvidia.com> Cc: Alex Sierra <alex.sierra@amd.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Alistair Popple <apopple@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent f09bddb commit fcab34b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

include/linux/mm.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,9 +1544,16 @@ static inline bool is_longterm_pinnable_page(struct page *page)
15441544
if (mt == MIGRATE_CMA || mt == MIGRATE_ISOLATE)
15451545
return false;
15461546
#endif
1547-
return !(is_device_coherent_page(page) ||
1548-
is_zone_movable_page(page) ||
1549-
is_zero_pfn(page_to_pfn(page)));
1547+
/* The zero page may always be pinned */
1548+
if (is_zero_pfn(page_to_pfn(page)))
1549+
return true;
1550+
1551+
/* Coherent device memory must always allow eviction. */
1552+
if (is_device_coherent_page(page))
1553+
return false;
1554+
1555+
/* Otherwise, non-movable zone pages can be pinned. */
1556+
return !is_zone_movable_page(page);
15501557
}
15511558
#else
15521559
static inline bool is_longterm_pinnable_page(struct page *page)

0 commit comments

Comments
 (0)