All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/hwpoison: fix build error without CONFIG_MEMORY_FAILURE
@ 2022-09-27 10:29 Hui Tang
  2022-09-27 12:16 ` Bagas Sanjaya
  2022-09-27 12:53 ` Naoya Horiguchi
  0 siblings, 2 replies; 5+ messages in thread
From: Hui Tang @ 2022-09-27 10:29 UTC (permalink / raw)
  To: naoya.horiguchi; +Cc: linmiaohe, akpm, linux-mm, linux-kernel, tanghui20

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")
Signed-off-by: Hui Tang <tanghui20@huawei.com>
---
 mm/memory-failure.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 03479895086d..5bb9d2d20234 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -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
 }
 
 /*
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/hwpoison: fix build error without CONFIG_MEMORY_FAILURE
  2022-09-27 10:29 [PATCH] mm/hwpoison: fix build error without CONFIG_MEMORY_FAILURE Hui Tang
@ 2022-09-27 12:16 ` Bagas Sanjaya
  2022-09-28  2:55   ` Hui Tang
  2022-09-27 12:53 ` Naoya Horiguchi
  1 sibling, 1 reply; 5+ messages in thread
From: Bagas Sanjaya @ 2022-09-27 12:16 UTC (permalink / raw)
  To: Hui Tang; +Cc: naoya.horiguchi, linmiaohe, akpm, linux-mm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

On Tue, Sep 27, 2022 at 06:29:46PM +0800, Hui Tang wrote:
> 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}.
> 

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

-- 
An old man doll... just what I always wanted! - Clara

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/hwpoison: fix build error without CONFIG_MEMORY_FAILURE
  2022-09-27 10:29 [PATCH] mm/hwpoison: fix build error without CONFIG_MEMORY_FAILURE Hui Tang
  2022-09-27 12:16 ` Bagas Sanjaya
@ 2022-09-27 12:53 ` Naoya Horiguchi
  2022-09-28  2:54   ` Hui Tang
  1 sibling, 1 reply; 5+ messages in thread
From: Naoya Horiguchi @ 2022-09-27 12:53 UTC (permalink / raw)
  To: Hui Tang; +Cc: naoya.horiguchi, linmiaohe, akpm, linux-mm, linux-kernel

On Tue, Sep 27, 2022 at 06:29:46PM +0800, Hui Tang wrote:
> 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")
> Signed-off-by: Hui Tang <tanghui20@huawei.com>

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/20220923095013.1151252-1-michael@walle.cc/
, 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/20220923141204.GA1484969@ik1-406-35019.vs.sakura.ne.jp/

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

> ---
>  mm/memory-failure.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 03479895086d..5bb9d2d20234 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -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
>  }
>  
>  /*
> -- 
> 2.17.1
> 
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/hwpoison: fix build error without CONFIG_MEMORY_FAILURE
  2022-09-27 12:53 ` Naoya Horiguchi
@ 2022-09-28  2:54   ` Hui Tang
  0 siblings, 0 replies; 5+ messages in thread
From: Hui Tang @ 2022-09-28  2:54 UTC (permalink / raw)
  To: Naoya Horiguchi; +Cc: naoya.horiguchi, linmiaohe, akpm, linux-mm, linux-kernel



On 2022/9/27 20:53, Naoya Horiguchi wrote:
> On Tue, Sep 27, 2022 at 06:29:46PM +0800, Hui Tang wrote:
>> 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")
>> Signed-off-by: Hui Tang <tanghui20@huawei.com>
>
> 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/20220923095013.1151252-1-michael@walle.cc/
> , 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/20220923141204.GA1484969@ik1-406-35019.vs.sakura.ne.jp/
>
> 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.

>
>> ---
>>  mm/memory-failure.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>> index 03479895086d..5bb9d2d20234 100644
>> --- a/mm/memory-failure.c
>> +++ b/mm/memory-failure.c
>> @@ -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
>>  }
>>
>>  /*
>> --
>> 2.17.1
>>
>>
>>
> .
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/hwpoison: fix build error without CONFIG_MEMORY_FAILURE
  2022-09-27 12:16 ` Bagas Sanjaya
@ 2022-09-28  2:55   ` Hui Tang
  0 siblings, 0 replies; 5+ messages in thread
From: Hui Tang @ 2022-09-28  2:55 UTC (permalink / raw)
  To: Bagas Sanjaya; +Cc: naoya.horiguchi, linmiaohe, akpm, linux-mm, linux-kernel



On 2022/9/27 20:16, Bagas Sanjaya wrote:
> On Tue, Sep 27, 2022 at 06:29:46PM +0800, Hui Tang wrote:
>> 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}.
>>
>
> Better say "Guard memblk_nr_poison_{inc,sub} under CONFIG_MEMORY_FAILURE".

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-28  2:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27 10:29 [PATCH] mm/hwpoison: fix build error without CONFIG_MEMORY_FAILURE Hui Tang
2022-09-27 12:16 ` Bagas Sanjaya
2022-09-28  2:55   ` Hui Tang
2022-09-27 12:53 ` Naoya Horiguchi
2022-09-28  2:54   ` Hui Tang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.