From: Kaitao Cheng <kaitao.cheng@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>,
"David Hildenbrand (Arm)" <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>,
"Liam R . Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Dan Williams <djbw@kernel.org>,
Vishal Verma <vishal.l.verma@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Alison Schofield <alison.schofield@intel.com>,
Ira Weiny <iweiny@kernel.org>,
Muchun Song <muchun.song@linux.dev>,
linux-mm@kvack.org, nvdimm@lists.linux.dev,
linux-kernel@vger.kernel.org,
Kaitao Cheng <chengkaitao@kylinos.cn>
Subject: Re: [PATCH 1/2] mm/page-flags: Define HWPoison test-and-change helpers unconditionally
Date: Sat, 26 Sep 2026 15:06:32 +0800 [thread overview]
Message-ID: <3e2690a2-06f9-4819-8e55-2129ab6566ab@linux.dev> (raw)
In-Reply-To: <20260925231908.25febf6c085f52be3a65d59b@linux-foundation.org>
在 2026/9/26 14:19, Andrew Morton 写道:
> On Mon, 7 Sep 2026 17:42:11 +0200 "David Hildenbrand (Arm)" <david@kernel.org> wrote:
>
>> On 9/3/26 07:35, Kaitao Cheng 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>
>>> ---
>>> 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
>>>
>>
>> Can we just squash this patch into #2 please?
>
> I did that.
I’ve also posted a v2 version.
https://lore.kernel.org/all/20260923055318.57485-1-kaitao.cheng@linux.dev/
>
> From: Kaitao Cheng <chengkaitao@kylinos.cn>
> Subject: mm/page-flags: define HWPoison test-and-change helpers unconditionally
> Date: Thu, 3 Sep 2026 13:35:34 +0800
>
> 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.
>
> Also remove now-unneeded test_and_clear_pmem_poison() from nvdimm/pmem.
>
> Link: https://lore.kernel.org/20260903053535.17611-1-kaitao.cheng@linux.dev
> Link: https://lore.kernel.org/20260903053535.17611-2-kaitao.cheng@linux.dev
> Link: https://lore.kernel.org/20260903053535.17611-3-kaitao.cheng@linux.dev
> Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Acked-by: Muchun Song <muchun.song@linux.dev>
> Acked-by: David Hildenbrand (Arm) <david@kernel.org>
> Reviewed-by: Oscar Salvador <osalvador@suse.de>
> Cc: Alison Schofield <alison.schofield@intel.com>
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Liam R. Howlett <liam@infradead.org>
> Cc: Lorenzo Stoakes <ljs@kernel.org>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Mike Rapoport <rppt@kernel.org>
> Cc: Suren Baghdasaryan <surenb@google.com>
> Cc: Vishal Verma <vishal.l.verma@intel.com>
> Cc: Vlastimil Babka <vbabka@kernel.org>
> Cc: Ira Weiny <iweiny@kernel.org>
> ---
>
> drivers/nvdimm/pmem.c | 2 +-
> drivers/nvdimm/pmem.h | 12 ------------
> include/linux/page-flags.h | 1 +
> 3 files changed, 2 insertions(+), 13 deletions(-)
>
> --- a/include/linux/page-flags.h~mm-page-flags-define-hwpoison-test-and-change-helpers-unconditionally
> +++ a/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
>
> --- a/drivers/nvdimm/pmem.c~mm-page-flags-define-hwpoison-test-and-change-helpers-unconditionally
> +++ a/drivers/nvdimm/pmem.c
> @@ -80,7 +80,7 @@ static void pmem_mkpage_present(struct p
> * 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);
> }
> }
> --- a/drivers/nvdimm/pmem.h~mm-page-flags-define-hwpoison-test-and-change-helpers-unconditionally
> +++ a/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_de
> 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__ */
> _
--
Thanks
Kaitao Cheng
next prev parent reply other threads:[~2026-09-26 7:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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-07 15:42 ` David Hildenbrand (Arm)
2026-09-26 6:19 ` Andrew Morton
2026-09-26 7:06 ` Kaitao Cheng [this message]
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
2026-09-07 15:42 ` David Hildenbrand (Arm)
2026-09-22 4:19 ` Oscar Salvador (SUSE)
2026-09-22 4:44 ` Kaitao Cheng
2026-09-22 13:57 ` David Hildenbrand (Arm)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3e2690a2-06f9-4819-8e55-2129ab6566ab@linux.dev \
--to=kaitao.cheng@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=alison.schofield@intel.com \
--cc=chengkaitao@kylinos.cn \
--cc=dave.jiang@intel.com \
--cc=david@kernel.org \
--cc=djbw@kernel.org \
--cc=iweiny@kernel.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=nvdimm@lists.linux.dev \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®