mm: Add three folio wrappers

folio_is_zone_device() is equivalent to is_zone_device_page(),
folio_is_device_private() is equivalent to is_device_private_page(),
and folio_is_pinnable() is equivalent to is_pinnable_page().

All of these tests return the same result for every page in the folio,
so we can just pass the head page of the folio to the page variant of
the function.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
This commit is contained in:
Matthew Wilcox (Oracle) 2022-03-21 12:57:38 -04:00
parent d1d8a3b4d0
commit 536939ff51
2 changed files with 15 additions and 0 deletions

View file

@ -138,6 +138,11 @@ static inline bool is_device_private_page(const struct page *page)
page->pgmap->type == MEMORY_DEVICE_PRIVATE; page->pgmap->type == MEMORY_DEVICE_PRIVATE;
} }
static inline bool folio_is_device_private(const struct folio *folio)
{
return is_device_private_page(&folio->page);
}
static inline bool is_pci_p2pdma_page(const struct page *page) static inline bool is_pci_p2pdma_page(const struct page *page)
{ {
return IS_ENABLED(CONFIG_PCI_P2PDMA) && return IS_ENABLED(CONFIG_PCI_P2PDMA) &&

View file

@ -1075,6 +1075,11 @@ static inline bool is_zone_device_page(const struct page *page)
} }
#endif #endif
static inline bool folio_is_zone_device(const struct folio *folio)
{
return is_zone_device_page(&folio->page);
}
static inline bool is_zone_movable_page(const struct page *page) static inline bool is_zone_movable_page(const struct page *page)
{ {
return page_zonenum(page) == ZONE_MOVABLE; return page_zonenum(page) == ZONE_MOVABLE;
@ -1556,6 +1561,11 @@ static inline bool is_pinnable_page(struct page *page)
} }
#endif #endif
static inline bool folio_is_pinnable(struct folio *folio)
{
return is_pinnable_page(&folio->page);
}
static inline void set_page_zone(struct page *page, enum zone_type zone) static inline void set_page_zone(struct page *page, enum zone_type zone)
{ {
page->flags &= ~(ZONES_MASK << ZONES_PGSHIFT); page->flags &= ~(ZONES_MASK << ZONES_PGSHIFT);