mm: introduce memdesc_nid()

Remove a conversion from folio to page by passing the folio->flags (which
are a copy of the page->flags) to the new memdesc_nid() function.

Link: https://lkml.kernel.org/r/20250805172307.1302730-4-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Matthew Wilcox (Oracle)
2025-08-05 18:22:53 +01:00
committed by Andrew Morton
parent 56d578c130
commit eb00fdd84d
2 changed files with 18 additions and 13 deletions

View File

@@ -1558,17 +1558,22 @@ static inline int page_zone_id(struct page *page)
}
#ifdef NODE_NOT_IN_PAGE_FLAGS
int page_to_nid(const struct page *page);
int memdesc_nid(memdesc_flags_t mdf);
#else
static inline int page_to_nid(const struct page *page)
static inline int memdesc_nid(memdesc_flags_t mdf)
{
return (PF_POISONED_CHECK(page)->flags.f >> NODES_PGSHIFT) & NODES_MASK;
return (mdf.f >> NODES_PGSHIFT) & NODES_MASK;
}
#endif
static inline int page_to_nid(const struct page *page)
{
return memdesc_nid(PF_POISONED_CHECK(page)->flags);
}
static inline int folio_nid(const struct folio *folio)
{
return page_to_nid(&folio->page);
return memdesc_nid(folio->flags);
}
#ifdef CONFIG_NUMA_BALANCING
@@ -1791,14 +1796,14 @@ static inline pg_data_t *page_pgdat(const struct page *page)
return NODE_DATA(page_to_nid(page));
}
static inline struct zone *folio_zone(const struct folio *folio)
{
return page_zone(&folio->page);
}
static inline pg_data_t *folio_pgdat(const struct folio *folio)
{
return page_pgdat(&folio->page);
return NODE_DATA(folio_nid(folio));
}
static inline struct zone *folio_zone(const struct folio *folio)
{
return &folio_pgdat(folio)->node_zones[folio_zonenum(folio)];
}
#ifdef SECTION_IN_PAGE_FLAGS

View File

@@ -43,11 +43,11 @@ static u8 section_to_node_table[NR_MEM_SECTIONS] __cacheline_aligned;
static u16 section_to_node_table[NR_MEM_SECTIONS] __cacheline_aligned;
#endif
int page_to_nid(const struct page *page)
int memdesc_nid(memdesc_flags_t mdf)
{
return section_to_node_table[memdesc_section(page->flags)];
return section_to_node_table[memdesc_section(mdf)];
}
EXPORT_SYMBOL(page_to_nid);
EXPORT_SYMBOL(memdesc_nid);
static void set_section_nid(unsigned long section_nr, int nid)
{