linux-next: build failure after merge of the mm tree

Stephen Rothwell posted 1 patch 3 years, 6 months ago
There is a newer version of this series
drivers/base/memory.c | 4 ++++
1 file changed, 4 insertions(+)
linux-next: build failure after merge of the mm tree
Posted by Stephen Rothwell 3 years, 6 months ago
Hi all,

After merging the mm tree, today's linux-next build (powerpc
ppc64_defconfig) failed like this:

drivers/base/memory.c: In function 'memory_block_online':
drivers/base/memory.c:186:34: error: 'struct memory_block' has no member named 'nr_hwpoison'
  186 |         if (atomic_long_read(&mem->nr_hwpoison))
      |                                  ^~
drivers/base/memory.c: In function 'remove_memory_block_devices':
drivers/base/memory.c:870:61: error: 'struct memory_block' has no member named 'nr_hwpoison'
  870 |                 clear_hwpoisoned_pages(atomic_long_read(&mem->nr_hwpoison));
      |                                                             ^~

Caused by commit

  69b496f03bb4 ("mm/hwpoison: introduce per-memory_block hwpoison counter")

This build has CONFIG_MEMORY_FAILURE not set.

I have applied the following fix patch for today.

From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Fri, 23 Sep 2022 17:50:50 +1000
Subject: [PATCH] fix up for "mm/hwpoison: introduce per-memory_block hwpoison counter"

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
 drivers/base/memory.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index c9bde4c4ffdf..143c63ceb4c3 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -183,8 +183,10 @@ static int memory_block_online(struct memory_block *mem)
 	struct zone *zone;
 	int ret;
 
+#ifdef CONFIG_MEMORY_FAILURE
 	if (atomic_long_read(&mem->nr_hwpoison))
 		return -EHWPOISON;
+#endif
 
 	zone = zone_for_pfn_range(mem->online_type, mem->nid, mem->group,
 				  start_pfn, nr_pages);
@@ -867,7 +869,9 @@ void remove_memory_block_devices(unsigned long start, unsigned long size)
 		mem = find_memory_block_by_id(block_id);
 		if (WARN_ON_ONCE(!mem))
 			continue;
+#ifdef CONFIG_MEMORY_FAILURE
 		clear_hwpoisoned_pages(atomic_long_read(&mem->nr_hwpoison));
+#endif
 		unregister_memory_block_under_nodes(mem);
 		remove_memory_block(mem);
 	}
-- 
2.35.1

-- 
Cheers,
Stephen Rothwell
Re: linux-next: build failure after merge of the mm tree
Posted by Michael Walle 3 years, 6 months ago
Hi,

> After merging the mm tree, today's linux-next build (powerpc
> ppc64_defconfig) failed like this:
> 
> drivers/base/memory.c: In function 'memory_block_online':
> drivers/base/memory.c:186:34: error: 'struct memory_block' has no member na=
> med 'nr_hwpoison'
>   186 |         if (atomic_long_read(&mem->nr_hwpoison))
>       |                                  ^~
> drivers/base/memory.c: In function 'remove_memory_block_devices':
> drivers/base/memory.c:870:61: error: 'struct memory_block' has no member na=
> med 'nr_hwpoison'
>   870 |                 clear_hwpoisoned_pages(atomic_long_read(&mem->nr_hw=
> poison));
>       |                                                             ^~
> 
> Caused by commit
> 
>   69b496f03bb4 ("mm/hwpoison: introduce per-memory_block hwpoison counter")
> 
> This build has CONFIG_MEMORY_FAILURE not set.

There also seems be more missing stubs. I'm getting:

aarch64-linux-gnu-ld: mm/memory-failure.o: in function `unpoison_memory':
memory-failure.c:(.text+0x1c38): undefined reference to `memblk_nr_poison_sub'
aarch64-linux-gnu-ld: mm/memory-failure.o: in function `num_poisoned_pages_inc':
memory-failure.c:(.text+0x2c8c): undefined reference to `memblk_nr_poison_inc'
aarch64-linux-gnu-ld: memory-failure.c:(.text+0x2cbc): undefined reference to `memblk_nr_poison_inc'

On a board where CONFIG_MEMORY_HOTPLUG is not set, but
CONFIG_MEMORY_FAILURE is. So either there are stubs missing or
MEMORY_FAILURE should depend MEMORY_HOTPLUG (?!).

-michael
Re: linux-next: build failure after merge of the mm tree
Posted by Naoya Horiguchi 3 years, 6 months ago
On Fri, Sep 23, 2022 at 11:50:13AM +0200, Michael Walle wrote:
> Hi,
> 
> > After merging the mm tree, today's linux-next build (powerpc
> > ppc64_defconfig) failed like this:
> > 
> > drivers/base/memory.c: In function 'memory_block_online':
> > drivers/base/memory.c:186:34: error: 'struct memory_block' has no member na=
> > med 'nr_hwpoison'
> >   186 |         if (atomic_long_read(&mem->nr_hwpoison))
> >       |                                  ^~
> > drivers/base/memory.c: In function 'remove_memory_block_devices':
> > drivers/base/memory.c:870:61: error: 'struct memory_block' has no member na=
> > med 'nr_hwpoison'
> >   870 |                 clear_hwpoisoned_pages(atomic_long_read(&mem->nr_hw=
> > poison));
> >       |                                                             ^~
> > 
> > Caused by commit
> > 
> >   69b496f03bb4 ("mm/hwpoison: introduce per-memory_block hwpoison counter")
> > 
> > This build has CONFIG_MEMORY_FAILURE not set.

Sorry for inconvenience, I submitted a possible fix hours ago,
https://lore.kernel.org/linux-mm/20220923081827.GA1357512@ik1-406-35019.vs.sakura.ne.jp/T/#t
I think the above build error should be fixed by this.

(the updated patch is here https://lore.kernel.org/linux-mm/20220923082613.GB1357512@ik1-406-35019.vs.sakura.ne.jp/T/#u)

But ...

> 
> There also seems be more missing stubs. I'm getting:
> 
> aarch64-linux-gnu-ld: mm/memory-failure.o: in function `unpoison_memory':
> memory-failure.c:(.text+0x1c38): undefined reference to `memblk_nr_poison_sub'
> aarch64-linux-gnu-ld: mm/memory-failure.o: in function `num_poisoned_pages_inc':
> memory-failure.c:(.text+0x2c8c): undefined reference to `memblk_nr_poison_inc'
> aarch64-linux-gnu-ld: memory-failure.c:(.text+0x2cbc): undefined reference to `memblk_nr_poison_inc'
> 
> On a board where CONFIG_MEMORY_HOTPLUG is not set, but
> CONFIG_MEMORY_FAILURE is. So either there are stubs missing or
> MEMORY_FAILURE should depend MEMORY_HOTPLUG (?!).

Yes, the new field ->nr_hwpoison is meaningful only when both settings are
enabled, so I need/will update #ifdef condition to check MEMORY_HOTPLUG.
In x86, CONFIG_MEMORY_HOTPLUG=n and CONFIG_MEMORY_FAILURE=y does not show
this error.  So this error might be caused by arch dependency.
Anyway I'll update the patch again soon.
Thank you for the report.

- Naoya Horiguchi