Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: convert page_to_section() to memdesc_section()

Pass in the memdesc_flags_t instead of a pointer to the page. This will
allow us to remove a few conversions to struct page in upcoming patches.

Link: https://lkml.kernel.org/r/20250805172307.1302730-3-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>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
56d578c1 53fbef56

+4 -4
+1 -1
include/asm-generic/memory_model.h
··· 53 53 */ 54 54 #define __page_to_pfn(pg) \ 55 55 ({ const struct page *__pg = (pg); \ 56 - int __sec = page_to_section(__pg); \ 56 + int __sec = memdesc_section(__pg->flags); \ 57 57 (unsigned long)(__pg - __section_mem_map_addr(__nr_to_section(__sec))); \ 58 58 }) 59 59
+2 -2
include/linux/mm.h
··· 1808 1808 page->flags.f |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT; 1809 1809 } 1810 1810 1811 - static inline unsigned long page_to_section(const struct page *page) 1811 + static inline unsigned long memdesc_section(memdesc_flags_t mdf) 1812 1812 { 1813 - return (page->flags.f >> SECTIONS_PGSHIFT) & SECTIONS_MASK; 1813 + return (mdf.f >> SECTIONS_PGSHIFT) & SECTIONS_MASK; 1814 1814 } 1815 1815 #endif 1816 1816
+1 -1
mm/sparse.c
··· 45 45 46 46 int page_to_nid(const struct page *page) 47 47 { 48 - return section_to_node_table[page_to_section(page)]; 48 + return section_to_node_table[memdesc_section(page->flags)]; 49 49 } 50 50 EXPORT_SYMBOL(page_to_nid); 51 51