Skip to contentSkip to conversation

mm/hwpoison: fix build error without CONFIG_MEMORY_FAILURE

PATCH In review Hui Tang 3 participants 5 messages Sep 27, 2022 – Sep 28, 2022

Subsystems (2)
lore
Share & tools
lore

Hui Tang

author
#0 lore raw

PATCH 1/1 mm/hwpoison: fix build error without CONFIG_MEMORY_FAILURE

Building without CONFIG_MEMORY_FAILURE will fail:

mm/memory-failure.o: In function `action_result':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function page_handle_poison':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function __get_huge_page_for_hwpoison':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function unpoison_memory':
memory-failure.c: undefined reference to memblk_nr_poison_sub' mm/memory-failure.o: In function num_poisoned_pages_inc':
memory-failure.c: undefined reference to `memblk_nr_poison_inc'

Add CONFIG_MEMORY_FAILURE wrapper for invoking memblk_nr_poison_{inc|sub}.

Fixes 69b496f03bb4 ("mm/hwpoison: introduce per-memory_block hwpoison counter")
---
 mm/memory-failure.c | 4 ++++
 1 file changed, 4 insertions(+)
mm/memory-failure.c +4 -0
index 03479895086d..5bb9d2d20234 100644
@@ -77,14 +77,18 @@ static bool hw_memory_failure __read_mostly = false;
 void num_poisoned_pages_inc(unsigned long pfn)
 {
 	atomic_long_inc(&num_poisoned_pages);
+#ifdef CONFIG_MEMORY_FAILURE
 	memblk_nr_poison_inc(pfn);
+#endif
 }
 
 static inline void num_poisoned_pages_sub(unsigned long pfn, long i)
 {
 	atomic_long_sub(i, &num_poisoned_pages);
+#ifdef CONFIG_MEMORY_FAILURE
 	if (pfn != -1UL)
 		memblk_nr_poison_sub(pfn, i);
+#endif
 }
 
 /*
Signature · 1 line
2.17.1
#1 lore raw
Quoted 13 lines · Hui Tang

Building without CONFIG_MEMORY_FAILURE will fail:

mm/memory-failure.o: In function `action_result':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function page_handle_poison':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function __get_huge_page_for_hwpoison':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function unpoison_memory':
memory-failure.c: undefined reference to memblk_nr_poison_sub' mm/memory-failure.o: In function num_poisoned_pages_inc':
memory-failure.c: undefined reference to `memblk_nr_poison_inc'

Quoted 2 lines

Add CONFIG_MEMORY_FAILURE wrapper for invoking memblk_nr_poison_{inc|sub}.

Better say "Guard memblk_nr_poison_{inc,sub} under CONFIG_MEMORY_FAILURE".

Signature · 1 line
An old man doll... just what I always wanted! - Clara
author
#2 lore raw
Quoted 14 lines · Bagas Sanjaya
Quoted 13 lines · Hui Tang

Building without CONFIG_MEMORY_FAILURE will fail:

mm/memory-failure.o: In function `action_result':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function page_handle_poison':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function __get_huge_page_for_hwpoison':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function unpoison_memory':
memory-failure.c: undefined reference to memblk_nr_poison_sub' mm/memory-failure.o: In function num_poisoned_pages_inc':
memory-failure.c: undefined reference to `memblk_nr_poison_inc'

Quoted 4 lines
Quoted 2 lines

Add CONFIG_MEMORY_FAILURE wrapper for invoking memblk_nr_poison_{inc|sub}.

Better say "Guard memblk_nr_poison_{inc,sub} under CONFIG_MEMORY_FAILURE".

Thanks.

#3 lore raw
In reply to Hui Tang
Quoted 13 lines · Hui Tang

Building without CONFIG_MEMORY_FAILURE will fail:

mm/memory-failure.o: In function `action_result':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function page_handle_poison':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function __get_huge_page_for_hwpoison':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function unpoison_memory':
memory-failure.c: undefined reference to memblk_nr_poison_sub' mm/memory-failure.o: In function num_poisoned_pages_inc':
memory-failure.c: undefined reference to `memblk_nr_poison_inc'

Quoted 4 lines

Add CONFIG_MEMORY_FAILURE wrapper for invoking memblk_nr_poison_{inc|sub}.

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

Thank you for the patch. I have a question.
If you disables CONFIG_MEMORY_FAILURE, mm/memory-failure.c should not be compiled, so I wonder why you saw the compile error. Could you share your .config file?

Acutally I saw the similar report a few days ago
https://lore.kernel.org/lkml/[email protected]/
, where the build error happened in aarch64, so I likely missed some arch dependency. I responded to the report by updating the patch by applying "#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_MEMORY_HOTPLUG)" to the definition of memblk_nr_poison_{inc,sub}.
https://lore.kernel.org/lkml/[email protected]/

I did not confirm that this fix is really right, because I can't reproduced the build error in my environment. So could you check that v5 patch fixes the build error you're seeing? (The current version in mm-unstable is v4, so that should be replaced with v5.)

Thanks,
Naoya Horiguchi

Quoted 32 lines
---
 mm/memory-failure.c | 4 ++++
 1 file changed, 4 insertions(+)
mm/memory-failure.c +4 -0
index 03479895086d..5bb9d2d20234 100644
@@ -77,14 +77,18 @@ static bool hw_memory_failure __read_mostly = false;
 void num_poisoned_pages_inc(unsigned long pfn)
 {
 	atomic_long_inc(&num_poisoned_pages);
+#ifdef CONFIG_MEMORY_FAILURE
 	memblk_nr_poison_inc(pfn);
+#endif
 }
 
 static inline void num_poisoned_pages_sub(unsigned long pfn, long i)
 {
 	atomic_long_sub(i, &num_poisoned_pages);
+#ifdef CONFIG_MEMORY_FAILURE
 	if (pfn != -1UL)
 		memblk_nr_poison_sub(pfn, i);
+#endif
 }
 
 /*
Signature · 1 line
2.17.1
author
#4 lore raw
Quoted 32 lines · Naoya Horiguchi
Quoted 13 lines · Hui Tang

Building without CONFIG_MEMORY_FAILURE will fail:

mm/memory-failure.o: In function `action_result':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function page_handle_poison':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function __get_huge_page_for_hwpoison':
memory-failure.c: undefined reference to memblk_nr_poison_inc' mm/memory-failure.o: In function unpoison_memory':
memory-failure.c: undefined reference to memblk_nr_poison_sub' mm/memory-failure.o: In function num_poisoned_pages_inc':
memory-failure.c: undefined reference to `memblk_nr_poison_inc'

Quoted 4 lines

Add CONFIG_MEMORY_FAILURE wrapper for invoking memblk_nr_poison_{inc|sub}.

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

Thank you for the patch. I have a question.
If you disables CONFIG_MEMORY_FAILURE, mm/memory-failure.c should not be compiled, so I wonder why you saw the compile error. Could you share your .config file?

Acutally I saw the similar report a few days ago
https://lore.kernel.org/lkml/[email protected]/
, where the build error happened in aarch64, so I likely missed some arch dependency. I responded to the report by updating the patch by applying "#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_MEMORY_HOTPLUG)" to the definition of memblk_nr_poison_{inc,sub}.
https://lore.kernel.org/lkml/[email protected]/

Quoted 4 lines

I did not confirm that this fix is really right, because I can't reproduced the build error in my environment. So could you check that v5 patch fixes the build error you're seeing? (The current version in mm-unstable is v4, so that should be replaced with v5.)

Yes, when appling the latest patch, this build error is gone, thanks.

Quoted 35 lines
Quoted 29 lines
---
 mm/memory-failure.c | 4 ++++
 1 file changed, 4 insertions(+)
mm/memory-failure.c +4 -1
index 03479895086d..5bb9d2d20234 100644
@@ -77,14 +77,18 @@ static bool hw_memory_failure __read_mostly = false;
 void num_poisoned_pages_inc(unsigned long pfn)
 {
 	atomic_long_inc(&num_poisoned_pages);
+#ifdef CONFIG_MEMORY_FAILURE
 	memblk_nr_poison_inc(pfn);
+#endif
 }
 
 static inline void num_poisoned_pages_sub(unsigned long pfn, long i)
 {
 	atomic_long_sub(i, &num_poisoned_pages);
+#ifdef CONFIG_MEMORY_FAILURE
 	if (pfn != -1UL)
 		memblk_nr_poison_sub(pfn, i);
+#endif
 }
 
 /*
--
Quoted 4 lines

2.17.1

.