Re: [PATCH v2 1/5] mm: introduce num_pages_contiguous()
From: lizhe . 67
Date: Sun Jul 06 2025 - 23:53:17 EST
On Sat, 5 Jul 2025 05:19:34 +0800, lkp@xxxxxxxxx wrote:
> All errors (new ones prefixed by >>):
>
> In file included from arch/sh/include/asm/page.h:160,
> from arch/sh/include/asm/thread_info.h:13,
> from include/linux/thread_info.h:60,
> from include/asm-generic/preempt.h:5,
> from ./arch/sh/include/generated/asm/preempt.h:1,
> from include/linux/preempt.h:79,
> from include/linux/spinlock.h:56,
> from include/linux/mmzone.h:8,
> from include/linux/gfp.h:7,
> from include/linux/mm.h:7,
> from arch/sh/kernel/asm-offsets.c:14:
> include/linux/mm.h: In function 'num_pages_contiguous':
> >> include/asm-generic/memory_model.h:48:21: error: implicit declaration of function 'page_to_section'; did you mean 'present_section'? [-Wimplicit-function-declaration]
> 48 | int __sec = page_to_section(__pg); \
> | ^~~~~~~~~~~~~~~
> include/asm-generic/memory_model.h:53:32: note: in definition of macro '__pfn_to_page'
> 53 | ({ unsigned long __pfn = (pfn); \
> | ^~~
> include/asm-generic/memory_model.h:65:21: note: in expansion of macro '__page_to_pfn'
> 65 | #define page_to_pfn __page_to_pfn
> | ^~~~~~~~~~~~~
> include/linux/mm.h:200:38: note: in expansion of macro 'page_to_pfn'
> 200 | #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
> | ^~~~~~~~~~~
> include/linux/mm.h:221:33: note: in expansion of macro 'nth_page'
> 221 | if (pages[i] != nth_page(first_page, i))
> | ^~~~~~~~
> include/linux/mm.h: At top level:
> >> include/linux/mm.h:2002:29: error: conflicting types for 'page_to_section'; have 'long unsigned int(const struct page *)'
> 2002 | static inline unsigned long page_to_section(const struct page *page)
> | ^~~~~~~~~~~~~~~
> include/asm-generic/memory_model.h:48:21: note: previous implicit declaration of 'page_to_section' with type 'int()'
> 48 | int __sec = page_to_section(__pg); \
> | ^~~~~~~~~~~~~~~
> include/asm-generic/memory_model.h:53:32: note: in definition of macro '__pfn_to_page'
> 53 | ({ unsigned long __pfn = (pfn); \
> | ^~~
> include/asm-generic/memory_model.h:65:21: note: in expansion of macro '__page_to_pfn'
> 65 | #define page_to_pfn __page_to_pfn
> | ^~~~~~~~~~~~~
> include/linux/mm.h:200:38: note: in expansion of macro 'page_to_pfn'
> 200 | #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
> | ^~~~~~~~~~~
> include/linux/mm.h:221:33: note: in expansion of macro 'nth_page'
> 221 | if (pages[i] != nth_page(first_page, i))
> | ^~~~~~~~
> make[3]: *** [scripts/Makefile.build:98: arch/sh/kernel/asm-offsets.s] Error 1
> make[3]: Target 'prepare' not remade because of errors.
> make[2]: *** [Makefile:1274: prepare0] Error 2
> make[2]: Target 'prepare' not remade because of errors.
> make[1]: *** [Makefile:248: __sub-make] Error 2
> make[1]: Target 'prepare' not remade because of errors.
> make: *** [Makefile:248: __sub-make] Error 2
> make: Target 'prepare' not remade because of errors.
>
>
> vim +2002 include/linux/mm.h
>
> bf4e8902ee5080 Daniel Kiper 2011-05-24 2001
> aa462abe8aaf21 Ian Campbell 2011-08-17 @2002 static inline unsigned long page_to_section(const struct page *page)
> d41dee369bff3b Andy Whitcroft 2005-06-23 2003 {
> d41dee369bff3b Andy Whitcroft 2005-06-23 2004 return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK;
> d41dee369bff3b Andy Whitcroft 2005-06-23 2005 }
> 308c05e35e3517 Christoph Lameter 2008-04-28 2006 #endif
> d41dee369bff3b Andy Whitcroft 2005-06-23 2007
Thank you. Let's move function num_pages_contiguous() below the
definition of page_to_section() to resolve this compilation error.
Thanks,
Zhe