From: "Gregory Price (Meta)" N_MEMORY_COMMON decides where ordinary allocations and node-scoped services go, but MM services that walk folios reach them through page tables, physical addresses or LRU lists, whatever node they are on. Add folio_is_common_memory() and page_is_common_memory() for those services. ZONE_DEVICE folios are never common memory, so the helpers can replace the folio_is_zone_device() and page_is_zone_device() checks those services already make. Following commits convert them. Signed-off-by: Gregory Price (Meta) --- mm/internal.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mm/internal.h b/mm/internal.h index c102e0f498bf..cd0562f0b68f 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -65,6 +65,21 @@ void folio_mark_lazyfree(struct folio *folio); void node_set_memory_state(int nid); void node_clear_memory_state(int nid); +/* + * Common memory is available to generic MM services. ZONE_DEVICE folios do + * not qualify even when their NUMA node is common. + */ +static inline bool folio_is_common_memory(struct folio *folio) +{ + return !folio_is_zone_device(folio) && + node_state(folio_nid(folio), N_MEMORY_COMMON); +} + +static inline bool page_is_common_memory(struct page *page) +{ + return folio_is_common_memory(page_folio(page)); +} + /* mm/vmscan.c */ unsigned long zone_reclaimable_pages(struct zone *zone); unsigned long try_to_free_pages(struct zonelist *zonelist, int order, -- 2.56.1