Re: [linux-next:master 5933/6583] include/linux/page_ext.h:131:20: error: call to undeclared function 'page_to_section'; ISO C99 and later do not support implicit function declarations
From: David Hildenbrand <hidden>
Date: 2025-02-28 13:17:28
Also in:
llvm, oe-kbuild-all
Subsystem:
memory management, memory management - page allocator, the rest · Maintainers:
Andrew Morton, Vlastimil Babka, Linus Torvalds
On 26.02.25 15:24, Luiz Capitulino wrote:
On 2025-02-26 09:10, Arnd Bergmann wrote:quoted
On Wed, Feb 26, 2025, at 10:46, kernel test robot wrote:quoted
commit: a2d6e9c1a867bb9f13943cb8483e2ab85b630bcd [5933/6583] mm: page_ext: add an iteration API for page extensions config: i386-buildonly-randconfig-004-20250226quoted
In file included from arch/x86/kernel/asm-offsets.c:14: In file included from include/linux/suspend.h:5: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:21: In file included from include/linux/mm.h:8: In file included from include/linux/pgalloc_tag.h:12:quoted
quoted
include/linux/page_ext.h:131:20: error: call to undeclared function 'page_to_section'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]131 | iter->start_pfn = page_to_pfn(page); | ^ include/asm-generic/memory_model.h:64:21: note: expanded from macro 'page_to_pfn' 64 | #define page_to_pfn __page_to_pfnI'm getting this on all configurations that set CONFIG_SPARSEMEM but not CONFIG_SPARSEMEM_VMMEMMAP.Oh, thanks. I didn't build with CONFIG_SPARSEMEM_VMEMMAP=n.quoted
There is also a possible problem with linux/page_ext.h including pgtable.h and mmzone.h, which I think can lead to circular header inclusions with linux/mm.h.Thanks, I'll look into this. Andrew, I think you'll have to drop this for now. I may not have the time to look into this this week.
If we feed lookup_page_ext() the PFN instead, and let the caller of page_ext_iter_begin() deal with the pfn_to_page(), we should be able to make it work. <linux/mmzone.h> still needs to be included, but I assume this should be fine for now. From a526d3819de7e36a45743d447638b7251881e508 Mon Sep 17 00:00:00 2001 From: David Hildenbrand <redacted> Date: Fri, 28 Feb 2025 14:10:15 +0100 Subject: [PATCH] tmp Signed-off-by: David Hildenbrand <redacted> --- include/linux/page_ext.h | 20 ++++++++++---------- mm/page_ext.c | 14 ++++++-------- 2 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h
index 33a118b31a222..0c4ff10969453 100644
--- a/include/linux/page_ext.h
+++ b/include/linux/page_ext.h@@ -2,7 +2,6 @@ #ifndef __LINUX_PAGE_EXT_H #define __LINUX_PAGE_EXT_H -#include <linux/pgtable.h> #include <linux/types.h> #include <linux/mmzone.h> #include <linux/stacktrace.h>
@@ -95,7 +94,7 @@ static inline bool page_ext_iter_next_fast_possible(unsigned long next_pfn) extern struct page_ext *page_ext_get(const struct page *page); extern void page_ext_put(struct page_ext *page_ext); -extern struct page_ext *lookup_page_ext(const struct page *page); +extern struct page_ext *lookup_page_ext(unsigned long pfn); static inline void *page_ext_data(struct page_ext *page_ext, struct page_ext_operations *ops)
@@ -119,17 +118,18 @@ struct page_ext_iter { /** * page_ext_iter_begin() - Prepare for iterating through page extensions. * @iter: page extension iterator. - * @page: The page we're interested in. + * @pfn: PFN of the page we're interested in. * * Must be called with RCU read lock taken. * * Return: NULL if no page_ext exists for this page. */ -static inline struct page_ext *page_ext_iter_begin(struct page_ext_iter *iter, struct page *page) +static inline struct page_ext *page_ext_iter_begin(struct page_ext_iter *iter, + unsigned long pfn) { iter->index = 0; - iter->start_pfn = page_to_pfn(page); - iter->page_ext = lookup_page_ext(page); + iter->start_pfn = pfn; + iter->page_ext = lookup_page_ext(iter->start_pfn); return iter->page_ext; }
@@ -155,7 +155,7 @@ static inline struct page_ext *page_ext_iter_next(struct page_ext_iter *iter) if (page_ext_iter_next_fast_possible(pfn)) iter->page_ext = page_ext_next(iter->page_ext); else - iter->page_ext = lookup_page_ext(pfn_to_page(pfn)); + iter->page_ext = lookup_page_ext(pfn); return iter->page_ext; }
@@ -181,9 +181,9 @@ static inline struct page_ext *page_ext_iter_get(const struct page_ext_iter *ite * * IMPORTANT: must be called with RCU read lock taken. */ -#define for_each_page_ext(__page, __pgcount, __page_ext, __iter) \ - for (__page_ext = page_ext_iter_begin(&__iter, __page); \ - __page_ext && __iter.index < __pgcount; \ +#define for_each_page_ext(__page, __pgcount, __page_ext, __iter) \ + for (__page_ext = page_ext_iter_begin(&__iter, page_to_pfn(__page)); \ + __page_ext && __iter.index < __pgcount; \ __page_ext = page_ext_iter_next(&__iter)) #else /* !CONFIG_PAGE_EXTENSION */
diff --git a/mm/page_ext.c b/mm/page_ext.c
index 23ad30597c05c..19cc0af9c5651 100644
--- a/mm/page_ext.c
+++ b/mm/page_ext.c@@ -165,14 +165,14 @@ void __meminit pgdat_page_ext_init(struct pglist_data *pgdat) pgdat->node_page_ext = NULL; } -struct page_ext *lookup_page_ext(const struct page *page) +struct page_ext *lookup_page_ext(unsigned long pfn) { - unsigned long pfn = page_to_pfn(page); + const int nid = page_to_nid(pfn_to_page(pfn)); unsigned long index; struct page_ext *base; WARN_ON_ONCE(!rcu_read_lock_held()); - base = NODE_DATA(page_to_nid(page))->node_page_ext; + base = NODE_DATA(nid)->node_page_ext; /* * The sanity checks the page allocator does upon freeing a * page can reach here before the page_ext arrays are
@@ -181,8 +181,7 @@ struct page_ext *lookup_page_ext(const struct page *page) */ if (unlikely(!base)) return NULL; - index = pfn - round_down(node_start_pfn(page_to_nid(page)), - MAX_ORDER_NR_PAGES); + index = pfn - round_down(node_start_pfn(nid), MAX_ORDER_NR_PAGES); return get_entry(base, index); }
@@ -245,9 +244,8 @@ static bool page_ext_invalid(struct page_ext *page_ext) return !page_ext || (((unsigned long)page_ext & PAGE_EXT_INVALID) == PAGE_EXT_INVALID); } -struct page_ext *lookup_page_ext(const struct page *page) +struct page_ext *lookup_page_ext(unsigned long pfn) { - unsigned long pfn = page_to_pfn(page); struct mem_section *section = __pfn_to_section(pfn); struct page_ext *page_ext = READ_ONCE(section->page_ext);
@@ -523,7 +521,7 @@ struct page_ext *page_ext_get(const struct page *page) struct page_ext *page_ext; rcu_read_lock(); - page_ext = lookup_page_ext(page); + page_ext = lookup_page_ext(page_to_pfn(page)); if (!page_ext) { rcu_read_unlock(); return NULL;
--
2.48.1
--
Cheers,
David / dhildenb