* [PATCH 0/2] Make HWPoison helpers config-independent
@ 2026-09-03 5:35 Kaitao Cheng
2026-09-03 5:35 ` [PATCH 1/2] mm/page-flags: Define HWPoison test-and-change helpers unconditionally Kaitao Cheng
2026-09-03 5:35 ` [PATCH 2/2] nvdimm/pmem: Remove test_and_clear_pmem_poison() Kaitao Cheng
0 siblings, 2 replies; 5+ messages in thread
From: Kaitao Cheng @ 2026-09-03 5:35 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
Make the HWPoison page flag's test-and-set and test-and-clear accessors
available regardless of CONFIG_MEMORY_FAILURE. When memory failure handling
is disabled, the accessors return false, matching the absence of HWPoison
state and providing a consistent interface across configurations.
Use the config-independent interface in the pmem driver to remove its
private test_and_clear_pmem_poison() wrapper and the associated header
dependency. No functional change is intended.
Kaitao Cheng (2):
mm/page-flags: Define HWPoison test-and-change helpers unconditionally
nvdimm/pmem: Remove test_and_clear_pmem_poison()
drivers/nvdimm/pmem.c | 2 +-
drivers/nvdimm/pmem.h | 12 ------------
include/linux/page-flags.h | 1 +
3 files changed, 2 insertions(+), 13 deletions(-)
--
2.50.1 (Apple Git-155)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] mm/page-flags: Define HWPoison test-and-change helpers unconditionally
2026-09-03 5:35 [PATCH 0/2] Make HWPoison helpers config-independent Kaitao Cheng
@ 2026-09-03 5:35 ` Kaitao Cheng
2026-09-03 6:15 ` Muchun Song
2026-09-03 5:35 ` [PATCH 2/2] nvdimm/pmem: Remove test_and_clear_pmem_poison() Kaitao Cheng
1 sibling, 1 reply; 5+ messages in thread
From: Kaitao Cheng @ 2026-09-03 5:35 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
From: Kaitao Cheng <chengkaitao@kylinos.cn>
Page flag helpers for configuration-dependent flags provide false or no-op
variants so that their users can be independent of the configuration.
The HWPoison helpers do not fully follow this pattern. When
CONFIG_MEMORY_FAILURE is enabled, PAGEFLAG() and TESTSCFLAG() provide the
regular, test-and-set, and test-and-clear operations. When it is disabled,
only PAGEFLAG_FALSE() is instantiated, leaving TestSetPageHWPoison() and
TestClearPageHWPoison() undefined.
Use TESTSCFLAG_FALSE() to provide the missing accessors when memory failure
handling is disabled. Both accessors return false, which is consistent with
HWPoison state being unavailable, and makes the accessor interface
consistent across configurations.
Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
---
include/linux/page-flags.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 7a863572adce..a2315ab1dd3a 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -656,6 +656,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.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mm/page-flags: Define HWPoison test-and-change helpers unconditionally
2026-09-03 5:35 ` [PATCH 1/2] mm/page-flags: Define HWPoison test-and-change helpers unconditionally Kaitao Cheng
@ 2026-09-03 6:15 ` Muchun Song
0 siblings, 0 replies; 5+ messages in thread
From: Muchun Song @ 2026-09-03 6:15 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, Alison Schofield, Ira Weiny, linux-mm, nvdimm,
linux-kernel, Kaitao Cheng
> On Sep 3, 2026, at 13:35, Kaitao Cheng <kaitao.cheng@linux.dev> wrote:
>
> From: Kaitao Cheng <chengkaitao@kylinos.cn>
>
> Page flag helpers for configuration-dependent flags provide false or no-op
> variants so that their users can be independent of the configuration.
>
> The HWPoison helpers do not fully follow this pattern. When
> CONFIG_MEMORY_FAILURE is enabled, PAGEFLAG() and TESTSCFLAG() provide the
> regular, test-and-set, and test-and-clear operations. When it is disabled,
> only PAGEFLAG_FALSE() is instantiated, leaving TestSetPageHWPoison() and
> TestClearPageHWPoison() undefined.
>
> Use TESTSCFLAG_FALSE() to provide the missing accessors when memory failure
> handling is disabled. Both accessors return false, which is consistent with
> HWPoison state being unavailable, and makes the accessor interface
> consistent across configurations.
>
> Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
Acked-by: Muchun Song <muchun.song@linux.dev>
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] nvdimm/pmem: Remove test_and_clear_pmem_poison()
2026-09-03 5:35 [PATCH 0/2] Make HWPoison helpers config-independent Kaitao Cheng
2026-09-03 5:35 ` [PATCH 1/2] mm/page-flags: Define HWPoison test-and-change helpers unconditionally Kaitao Cheng
@ 2026-09-03 5:35 ` Kaitao Cheng
2026-09-03 6:17 ` Muchun Song
1 sibling, 1 reply; 5+ messages in thread
From: Kaitao Cheng @ 2026-09-03 5:35 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
From: Kaitao Cheng <chengkaitao@kylinos.cn>
TestClearPageHWPoison() is now defined regardless of whether
CONFIG_MEMORY_FAILURE is enabled, returning false when memory failure
handling is unavailable.
The test_and_clear_pmem_poison() wrapper duplicates this configuration
handling and has no other pmem-specific behavior.
Call TestClearPageHWPoison() directly and remove the redundant wrapper.
This also removes the need to include page-flags.h from pmem.h.
No functional change is intended.
Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
---
drivers/nvdimm/pmem.c | 2 +-
drivers/nvdimm/pmem.h | 12 ------------
2 files changed, 1 insertion(+), 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__ */
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] nvdimm/pmem: Remove test_and_clear_pmem_poison()
2026-09-03 5:35 ` [PATCH 2/2] nvdimm/pmem: Remove test_and_clear_pmem_poison() Kaitao Cheng
@ 2026-09-03 6:17 ` Muchun Song
0 siblings, 0 replies; 5+ messages in thread
From: Muchun Song @ 2026-09-03 6:17 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, Alison Schofield, Ira Weiny, linux-mm, nvdimm,
linux-kernel, Kaitao Cheng
> On Sep 3, 2026, at 13:35, Kaitao Cheng <kaitao.cheng@linux.dev> wrote:
>
> From: Kaitao Cheng <chengkaitao@kylinos.cn>
>
> TestClearPageHWPoison() is now defined regardless of whether
> CONFIG_MEMORY_FAILURE is enabled, returning false when memory failure
> handling is unavailable.
>
> The test_and_clear_pmem_poison() wrapper duplicates this configuration
> handling and has no other pmem-specific behavior.
>
> Call TestClearPageHWPoison() directly and remove the redundant wrapper.
> This also removes the need to include page-flags.h from pmem.h.
>
> No functional change is intended.
>
> Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
The code becomes simpler.
Acked-by: Muchun Song <muchun.song@linux.dev>
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-03 6:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-03 5:35 [PATCH 0/2] Make HWPoison helpers config-independent Kaitao Cheng
2026-09-03 5:35 ` [PATCH 1/2] mm/page-flags: Define HWPoison test-and-change helpers unconditionally Kaitao Cheng
2026-09-03 6:15 ` Muchun Song
2026-09-03 5:35 ` [PATCH 2/2] nvdimm/pmem: Remove test_and_clear_pmem_poison() Kaitao Cheng
2026-09-03 6:17 ` Muchun Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox