Skip to content

Commit

Permalink
mm: re-allow pinning of zero pfns (again)
Browse files Browse the repository at this point in the history
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.

[[email protected]: 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 <[email protected]>
Suggested-by: Matthew Wilcox <[email protected]>
Suggested-by: Felix Kuehling <[email protected]>
Tested-by: Slawomir Laba <[email protected]>
Reviewed-by: John Hubbard <[email protected]>
Cc: Alex Sierra <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Alistair Popple <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
awilliam authored and akpm00 committed Aug 28, 2022
1 parent f09bddb commit fcab34b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1544,9 +1544,16 @@ static inline bool is_longterm_pinnable_page(struct page *page)
if (mt == MIGRATE_CMA || mt == MIGRATE_ISOLATE)
return false;
#endif
return !(is_device_coherent_page(page) ||
is_zone_movable_page(page) ||
is_zero_pfn(page_to_pfn(page)));
/* The zero page may always be pinned */
if (is_zero_pfn(page_to_pfn(page)))
return true;

/* Coherent device memory must always allow eviction. */
if (is_device_coherent_page(page))
return false;

/* Otherwise, non-movable zone pages can be pinned. */
return !is_zone_movable_page(page);
}
#else
static inline bool is_longterm_pinnable_page(struct page *page)
Expand Down

0 comments on commit fcab34b

Please sign in to comment.