diff mbox series

[RFC,v2,1/8] page_flags: add is_folio_hwpoison()

Message ID 20230526075552.363524-2-mcgrof@kernel.org (mailing list archive)
State New
Headers show
Series add support for blocksize > PAGE_SIZE | expand

Commit Message

Luis Chamberlain May 26, 2023, 7:55 a.m. UTC
Provide a helper similar to is_page_hwpoison() for folios
which tests the first head and if the folio is large any page in
the folio is tested for the poison flag.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 include/linux/page-flags.h | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Matthew Wilcox May 26, 2023, 1:51 p.m. UTC | #1
On Fri, May 26, 2023 at 12:55:45AM -0700, Luis Chamberlain wrote:
> Provide a helper similar to is_page_hwpoison() for folios
> which tests the first head and if the folio is large any page in
> the folio is tested for the poison flag.

But it's not "is poison".  it's "contains poison".  So how about
folio_contains_hwpoison() as a name?

But what do you really want to know here?  In the Glorious Future,
individual pages get their memdesc pointer set to be a hwpoison
pointer.  Are we going to need to retain a bit in every memdesc to
say whether one of the pages in the memdesc has been poisoned?

Or can we get away with just testing individual pages as we look at
them?
Keith Busch May 26, 2023, 3:40 p.m. UTC | #2
On Fri, May 26, 2023 at 02:51:34PM +0100, Matthew Wilcox wrote:
> On Fri, May 26, 2023 at 12:55:45AM -0700, Luis Chamberlain wrote:
> > Provide a helper similar to is_page_hwpoison() for folios
> > which tests the first head and if the folio is large any page in
> > the folio is tested for the poison flag.
> 
> But it's not "is poison".  it's "contains poison".  So how about
> folio_contains_hwpoison() as a name?

Would a smaller change in tense to "is poisoned" also work? I think
that's mostly synonymous to "contains poison".
diff mbox series

Patch

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 1c68d67b832f..4d5f395edf03 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -883,6 +883,13 @@  static inline bool is_page_hwpoison(struct page *page)
 	return PageHuge(page) && PageHWPoison(compound_head(page));
 }
 
+static inline bool is_folio_hwpoison(struct folio *folio)
+{
+       if (folio_test_hwpoison(folio))
+               return true;
+       return folio_test_large(folio) && folio_test_has_hwpoisoned(folio);
+}
+
 /*
  * For pages that are never mapped to userspace (and aren't PageSlab),
  * page_type may be used.  Because it is initialised to -1, we invert the