* [PATCH v2] nvdimm/pmem: remove test_and_clear_pmem_poison()
@ 2026-09-23 5:53 Kaitao Cheng
2026-10-02 3:03 ` Dave Jiang
2026-10-10 2:14 ` Alison Schofield
0 siblings, 2 replies; 4+ messages in thread
From: Kaitao Cheng @ 2026-09-23 5:53 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R . Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Dan Williams, Vishal Verma,
Dave Jiang, Alison Schofield, Ira Weiny
Cc: Muchun Song, linux-mm, nvdimm, linux-kernel, Kaitao Cheng,
Oscar Salvador
From: Kaitao Cheng <chengkaitao@kylinos.cn>
The pmem driver provides test_and_clear_pmem_poison() only to handle
the CONFIG_MEMORY_FAILURE dependency of TestClearPageHWPoison().
The wrapper has no other pmem-specific behavior.
Define the HWPoison test-and-change helpers to return false when
CONFIG_MEMORY_FAILURE is disabled. This allows pmem to call
TestClearPageHWPoison() directly in all configurations.
Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
Changes in v2 (David Hildenbrand, Oscar Salvador):
- squash patch#1 into patch#2.
Link to v1:
https://lore.kernel.org/all/20260903053535.17611-1-kaitao.cheng@linux.dev/
---
drivers/nvdimm/pmem.c | 2 +-
drivers/nvdimm/pmem.h | 12 ------------
include/linux/page-flags.h | 1 +
3 files changed, 2 insertions(+), 13 deletions(-)
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 30a51c365ce8..5fb86595e8bd 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -80,7 +80,7 @@ static void pmem_mkpage_present(struct pmem_device *pmem, phys_addr_t offset,
* here since we're in the driver I/O path and
* outstanding I/O requests pin the dev_pagemap.
*/
- if (test_and_clear_pmem_poison(page))
+ if (TestClearPageHWPoison(page))
clear_mce_nospec(pfn);
}
}
diff --git a/drivers/nvdimm/pmem.h b/drivers/nvdimm/pmem.h
index a48509f90196..76870505dd79 100644
--- a/drivers/nvdimm/pmem.h
+++ b/drivers/nvdimm/pmem.h
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __NVDIMM_PMEM_H__
#define __NVDIMM_PMEM_H__
-#include <linux/page-flags.h>
#include <linux/badblocks.h>
#include <linux/memremap.h>
#include <linux/types.h>
@@ -31,15 +30,4 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff,
long nr_pages, enum dax_access_mode mode, void **kaddr,
unsigned long *pfn);
-#ifdef CONFIG_MEMORY_FAILURE
-static inline bool test_and_clear_pmem_poison(struct page *page)
-{
- return TestClearPageHWPoison(page);
-}
-#else
-static inline bool test_and_clear_pmem_poison(struct page *page)
-{
- return false;
-}
-#endif
#endif /* __NVDIMM_PMEM_H__ */
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index ae2ebaed6d4d..3dc79c0c5adf 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -655,6 +655,7 @@ TESTSCFLAG(HWPoison, hwpoison, PF_ANY)
#define __PG_HWPOISON (1UL << PG_hwpoison)
#else
PAGEFLAG_FALSE(HWPoison, hwpoison)
+TESTSCFLAG_FALSE(HWPoison, hwpoison)
#define __PG_HWPOISON 0
#endif
--
2.54.0 (Apple Git-157)
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] nvdimm/pmem: remove test_and_clear_pmem_poison()
2026-09-23 5:53 [PATCH v2] nvdimm/pmem: remove test_and_clear_pmem_poison() Kaitao Cheng
@ 2026-10-02 3:03 ` Dave Jiang
2026-10-10 2:14 ` Alison Schofield
1 sibling, 0 replies; 4+ messages in thread
From: Dave Jiang @ 2026-10-02 3:03 UTC (permalink / raw)
To: Kaitao Cheng, Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R . Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Dan Williams, Vishal Verma,
Alison Schofield, Ira Weiny
Cc: Muchun Song, linux-mm, nvdimm, linux-kernel, Kaitao Cheng,
Oscar Salvador
On 9/22/26 10:53 PM, Kaitao Cheng wrote:
> From: Kaitao Cheng <chengkaitao@kylinos.cn>
>
> The pmem driver provides test_and_clear_pmem_poison() only to handle
> the CONFIG_MEMORY_FAILURE dependency of TestClearPageHWPoison().
> The wrapper has no other pmem-specific behavior.
>
> Define the HWPoison test-and-change helpers to return false when
> CONFIG_MEMORY_FAILURE is disabled. This allows pmem to call
> TestClearPageHWPoison() directly in all configurations.
>
> Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
> Acked-by: David Hildenbrand (Arm) <david@kernel.org>
> Acked-by: Muchun Song <muchun.song@linux.dev>
> Reviewed-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> Changes in v2 (David Hildenbrand, Oscar Salvador):
> - squash patch#1 into patch#2.
>
> Link to v1:
> https://lore.kernel.org/all/20260903053535.17611-1-kaitao.cheng@linux.dev/
> ---
> drivers/nvdimm/pmem.c | 2 +-
> drivers/nvdimm/pmem.h | 12 ------------
> include/linux/page-flags.h | 1 +
> 3 files changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
> index 30a51c365ce8..5fb86595e8bd 100644
> --- a/drivers/nvdimm/pmem.c
> +++ b/drivers/nvdimm/pmem.c
> @@ -80,7 +80,7 @@ static void pmem_mkpage_present(struct pmem_device *pmem, phys_addr_t offset,
> * here since we're in the driver I/O path and
> * outstanding I/O requests pin the dev_pagemap.
> */
> - if (test_and_clear_pmem_poison(page))
> + if (TestClearPageHWPoison(page))
> clear_mce_nospec(pfn);
> }
> }
> diff --git a/drivers/nvdimm/pmem.h b/drivers/nvdimm/pmem.h
> index a48509f90196..76870505dd79 100644
> --- a/drivers/nvdimm/pmem.h
> +++ b/drivers/nvdimm/pmem.h
> @@ -1,7 +1,6 @@
> /* SPDX-License-Identifier: GPL-2.0 */
> #ifndef __NVDIMM_PMEM_H__
> #define __NVDIMM_PMEM_H__
> -#include <linux/page-flags.h>
> #include <linux/badblocks.h>
> #include <linux/memremap.h>
> #include <linux/types.h>
> @@ -31,15 +30,4 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff,
> long nr_pages, enum dax_access_mode mode, void **kaddr,
> unsigned long *pfn);
>
> -#ifdef CONFIG_MEMORY_FAILURE
> -static inline bool test_and_clear_pmem_poison(struct page *page)
> -{
> - return TestClearPageHWPoison(page);
> -}
> -#else
> -static inline bool test_and_clear_pmem_poison(struct page *page)
> -{
> - return false;
> -}
> -#endif
> #endif /* __NVDIMM_PMEM_H__ */
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index ae2ebaed6d4d..3dc79c0c5adf 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -655,6 +655,7 @@ TESTSCFLAG(HWPoison, hwpoison, PF_ANY)
> #define __PG_HWPOISON (1UL << PG_hwpoison)
> #else
> PAGEFLAG_FALSE(HWPoison, hwpoison)
> +TESTSCFLAG_FALSE(HWPoison, hwpoison)
> #define __PG_HWPOISON 0
> #endif
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] nvdimm/pmem: remove test_and_clear_pmem_poison()
2026-09-23 5:53 [PATCH v2] nvdimm/pmem: remove test_and_clear_pmem_poison() Kaitao Cheng
2026-10-02 3:03 ` Dave Jiang
@ 2026-10-10 2:14 ` Alison Schofield
2026-10-10 3:57 ` Kaitao Cheng
1 sibling, 1 reply; 4+ messages in thread
From: Alison Schofield @ 2026-10-10 2:14 UTC (permalink / raw)
To: Kaitao Cheng
Cc: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R . Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Dan Williams, Vishal Verma,
Dave Jiang, Ira Weiny, Muchun Song, linux-mm, nvdimm,
linux-kernel, Kaitao Cheng, Oscar Salvador
On Wed, Sep 23, 2026 at 01:53:18PM +0800, Kaitao Cheng wrote:
> From: Kaitao Cheng <chengkaitao@kylinos.cn>
>
> The pmem driver provides test_and_clear_pmem_poison() only to handle
> the CONFIG_MEMORY_FAILURE dependency of TestClearPageHWPoison().
> The wrapper has no other pmem-specific behavior.
>
> Define the HWPoison test-and-change helpers to return false when
> CONFIG_MEMORY_FAILURE is disabled. This allows pmem to call
> TestClearPageHWPoison() directly in all configurations.
I see this merged here:
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/commit/?h=mm-stable&id=2492d9c0afc02cebe8318155829e7d03bea617b8
Still not sure how all that works, but I got an email saying merged, yet
this list was not on the email thread.
>
> Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
> Acked-by: David Hildenbrand (Arm) <david@kernel.org>
> Acked-by: Muchun Song <muchun.song@linux.dev>
> Reviewed-by: Oscar Salvador <osalvador@suse.de>
> ---
> Changes in v2 (David Hildenbrand, Oscar Salvador):
> - squash patch#1 into patch#2.
>
> Link to v1:
> https://lore.kernel.org/all/20260903053535.17611-1-kaitao.cheng@linux.dev/
> ---
> drivers/nvdimm/pmem.c | 2 +-
> drivers/nvdimm/pmem.h | 12 ------------
> include/linux/page-flags.h | 1 +
> 3 files changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
> index 30a51c365ce8..5fb86595e8bd 100644
> --- a/drivers/nvdimm/pmem.c
> +++ b/drivers/nvdimm/pmem.c
> @@ -80,7 +80,7 @@ static void pmem_mkpage_present(struct pmem_device *pmem, phys_addr_t offset,
> * here since we're in the driver I/O path and
> * outstanding I/O requests pin the dev_pagemap.
> */
> - if (test_and_clear_pmem_poison(page))
> + if (TestClearPageHWPoison(page))
> clear_mce_nospec(pfn);
> }
> }
> diff --git a/drivers/nvdimm/pmem.h b/drivers/nvdimm/pmem.h
> index a48509f90196..76870505dd79 100644
> --- a/drivers/nvdimm/pmem.h
> +++ b/drivers/nvdimm/pmem.h
> @@ -1,7 +1,6 @@
> /* SPDX-License-Identifier: GPL-2.0 */
> #ifndef __NVDIMM_PMEM_H__
> #define __NVDIMM_PMEM_H__
> -#include <linux/page-flags.h>
> #include <linux/badblocks.h>
> #include <linux/memremap.h>
> #include <linux/types.h>
> @@ -31,15 +30,4 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff,
> long nr_pages, enum dax_access_mode mode, void **kaddr,
> unsigned long *pfn);
>
> -#ifdef CONFIG_MEMORY_FAILURE
> -static inline bool test_and_clear_pmem_poison(struct page *page)
> -{
> - return TestClearPageHWPoison(page);
> -}
> -#else
> -static inline bool test_and_clear_pmem_poison(struct page *page)
> -{
> - return false;
> -}
> -#endif
> #endif /* __NVDIMM_PMEM_H__ */
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index ae2ebaed6d4d..3dc79c0c5adf 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -655,6 +655,7 @@ TESTSCFLAG(HWPoison, hwpoison, PF_ANY)
> #define __PG_HWPOISON (1UL << PG_hwpoison)
> #else
> PAGEFLAG_FALSE(HWPoison, hwpoison)
> +TESTSCFLAG_FALSE(HWPoison, hwpoison)
> #define __PG_HWPOISON 0
> #endif
>
> --
> 2.54.0 (Apple Git-157)
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] nvdimm/pmem: remove test_and_clear_pmem_poison()
2026-10-10 2:14 ` Alison Schofield
@ 2026-10-10 3:57 ` Kaitao Cheng
0 siblings, 0 replies; 4+ messages in thread
From: Kaitao Cheng @ 2026-10-10 3:57 UTC (permalink / raw)
To: Alison Schofield
Cc: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R . Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Dan Williams, Vishal Verma,
Dave Jiang, Ira Weiny, Muchun Song, linux-mm, nvdimm,
linux-kernel, Kaitao Cheng, Oscar Salvador
在 2026/10/10 10:14, Alison Schofield 写道:
> On Wed, Sep 23, 2026 at 01:53:18PM +0800, Kaitao Cheng wrote:
>> From: Kaitao Cheng <chengkaitao@kylinos.cn>
>>
>> The pmem driver provides test_and_clear_pmem_poison() only to handle
>> the CONFIG_MEMORY_FAILURE dependency of TestClearPageHWPoison().
>> The wrapper has no other pmem-specific behavior.
>>
>> Define the HWPoison test-and-change helpers to return false when
>> CONFIG_MEMORY_FAILURE is disabled. This allows pmem to call
>> TestClearPageHWPoison() directly in all configurations.
>
> I see this merged here:
> https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/commit/?h=mm-stable&id=2492d9c0afc02cebe8318155829e7d03bea617b8
>
> Still not sure how all that works, but I got an email saying merged, yet
> this list was not on the email thread.
Andrew Morton probably thought the change was straightforward, so he made the
adjustment himself and merged it. There’s nothing wrong with the code itself.
>>
>> Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
>> Acked-by: David Hildenbrand (Arm) <david@kernel.org>
>> Acked-by: Muchun Song <muchun.song@linux.dev>
>> Reviewed-by: Oscar Salvador <osalvador@suse.de>
>> ---
>> Changes in v2 (David Hildenbrand, Oscar Salvador):
>> - squash patch#1 into patch#2.
>>
>> Link to v1:
>> https://lore.kernel.org/all/20260903053535.17611-1-kaitao.cheng@linux.dev/
>> ---
>> drivers/nvdimm/pmem.c | 2 +-
>> drivers/nvdimm/pmem.h | 12 ------------
>> include/linux/page-flags.h | 1 +
>> 3 files changed, 2 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
>> index 30a51c365ce8..5fb86595e8bd 100644
>> --- a/drivers/nvdimm/pmem.c
>> +++ b/drivers/nvdimm/pmem.c
>> @@ -80,7 +80,7 @@ static void pmem_mkpage_present(struct pmem_device *pmem, phys_addr_t offset,
>> * here since we're in the driver I/O path and
>> * outstanding I/O requests pin the dev_pagemap.
>> */
>> - if (test_and_clear_pmem_poison(page))
>> + if (TestClearPageHWPoison(page))
>> clear_mce_nospec(pfn);
>> }
>> }
>> diff --git a/drivers/nvdimm/pmem.h b/drivers/nvdimm/pmem.h
>> index a48509f90196..76870505dd79 100644
>> --- a/drivers/nvdimm/pmem.h
>> +++ b/drivers/nvdimm/pmem.h
>> @@ -1,7 +1,6 @@
>> /* SPDX-License-Identifier: GPL-2.0 */
>> #ifndef __NVDIMM_PMEM_H__
>> #define __NVDIMM_PMEM_H__
>> -#include <linux/page-flags.h>
>> #include <linux/badblocks.h>
>> #include <linux/memremap.h>
>> #include <linux/types.h>
>> @@ -31,15 +30,4 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff,
>> long nr_pages, enum dax_access_mode mode, void **kaddr,
>> unsigned long *pfn);
>>
>> -#ifdef CONFIG_MEMORY_FAILURE
>> -static inline bool test_and_clear_pmem_poison(struct page *page)
>> -{
>> - return TestClearPageHWPoison(page);
>> -}
>> -#else
>> -static inline bool test_and_clear_pmem_poison(struct page *page)
>> -{
>> - return false;
>> -}
>> -#endif
>> #endif /* __NVDIMM_PMEM_H__ */
>> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
>> index ae2ebaed6d4d..3dc79c0c5adf 100644
>> --- a/include/linux/page-flags.h
>> +++ b/include/linux/page-flags.h
>> @@ -655,6 +655,7 @@ TESTSCFLAG(HWPoison, hwpoison, PF_ANY)
>> #define __PG_HWPOISON (1UL << PG_hwpoison)
>> #else
>> PAGEFLAG_FALSE(HWPoison, hwpoison)
>> +TESTSCFLAG_FALSE(HWPoison, hwpoison)
>> #define __PG_HWPOISON 0
>> #endif
>>
>> --
>> 2.54.0 (Apple Git-157)
>>
--
Thanks
Kaitao Cheng
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-10 3:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-23 5:53 [PATCH v2] nvdimm/pmem: remove test_and_clear_pmem_poison() Kaitao Cheng
2026-10-02 3:03 ` Dave Jiang
2026-10-10 2:14 ` Alison Schofield
2026-10-10 3:57 ` Kaitao Cheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®