Skip to content

Commit

Permalink
mm: remove is_longterm_pinnable_page() and reimplement folio_is_longt…
Browse files Browse the repository at this point in the history
…erm_pinnable()

folio_is_longterm_pinnable() already exists as a wrapper function.  Now
that the whole implementation of is_longterm_pinnable_page() can be
implemented using folios, folio_is_longterm_pinnable() can be made its own
standalone function - and we can remove is_longterm_pinnable_page().

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Vishal Moola (Oracle) <[email protected]>
Reviewed-by: Matthew Wilcox (Oracle) <[email protected]>
Reviewed-by: Lorenzo Stoakes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
VMoola authored and akpm00 committed Jun 19, 2023
1 parent 503670e commit 5d94995
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1902,39 +1902,35 @@ static inline bool page_needs_cow_for_dma(struct vm_area_struct *vma,
return page_maybe_dma_pinned(page);
}

/* MIGRATE_CMA and ZONE_MOVABLE do not allow pin pages */
/* MIGRATE_CMA and ZONE_MOVABLE do not allow pin folios */
#ifdef CONFIG_MIGRATION
static inline bool is_longterm_pinnable_page(struct page *page)
static inline bool folio_is_longterm_pinnable(struct folio *folio)
{
#ifdef CONFIG_CMA
int mt = get_pageblock_migratetype(page);
int mt = folio_migratetype(folio);

if (mt == MIGRATE_CMA || mt == MIGRATE_ISOLATE)
return false;
#endif
/* The zero page may always be pinned */
if (is_zero_pfn(page_to_pfn(page)))
if (is_zero_pfn(folio_pfn(folio)))
return true;

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

/* Otherwise, non-movable zone pages can be pinned. */
return !is_zone_movable_page(page);
/* Otherwise, non-movable zone folios can be pinned. */
return !folio_is_zone_movable(folio);

}
#else
static inline bool is_longterm_pinnable_page(struct page *page)
static inline bool folio_is_longterm_pinnable(struct folio *folio)
{
return true;
}
#endif

static inline bool folio_is_longterm_pinnable(struct folio *folio)
{
return is_longterm_pinnable_page(&folio->page);
}

static inline void set_page_zone(struct page *page, enum zone_type zone)
{
page->flags &= ~(ZONES_MASK << ZONES_PGSHIFT);
Expand Down

0 comments on commit 5d94995

Please sign in to comment.