linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Luiz Capitulino <luizcap@redhat.com>,
	Arnd Bergmann <arnd@arndb.de>, kernel test robot <lkp@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	Linux Memory Management List <linux-mm@kvack.org>
Subject: 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
Date: Fri, 28 Feb 2025 14:17:20 +0100	[thread overview]
Message-ID: <58c86080-94a1-449c-8186-eb6478a9653a@redhat.com> (raw)
In-Reply-To: <8cece92a-6ad0-43fe-9916-eeb850c039e1@redhat.com>

On 26.02.25 15:24, Luiz Capitulino wrote:
> On 2025-02-26 09:10, Arnd Bergmann wrote:
>> On Wed, Feb 26, 2025, at 10:46, kernel test robot wrote:
>>> commit: a2d6e9c1a867bb9f13943cb8483e2ab85b630bcd [5933/6583] mm:
>>> page_ext: add an iteration API for page extensions
>>> config: i386-buildonly-randconfig-004-20250226
>>
>>>
>>>      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:
>>>>> 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_pfn
>>
>> I'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.
> 
>> 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 <david@redhat.com>
Date: Fri, 28 Feb 2025 14:10:15 +0100
Subject: [PATCH] tmp

Signed-off-by: David Hildenbrand <david@redhat.com>
---
  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



      parent reply	other threads:[~2025-02-28 13:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-26  9:46 kernel test robot
2025-02-26 14:10 ` Arnd Bergmann
2025-02-26 14:24   ` Luiz Capitulino
2025-02-26 20:31     ` Andrew Morton
2025-02-28 13:17     ` David Hildenbrand [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58c86080-94a1-449c-8186-eb6478a9653a@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=luizcap@redhat.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox