linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: Pankaj Raghav <p.raghav@samsung.com>,
	hughd@google.com, willy@infradead.org
Cc: akpm@linux-foundation.org, brauner@kernel.org, djwong@kernel.org,
	da.gomez@samsung.com, a.manzanares@samsung.com,
	dave@stgolabs.net, yosryahmed@google.com, keescook@chromium.org,
	hare@suse.de, kbusch@kernel.org, patches@lists.linux.dev,
	linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC 2/8] shmem: convert to use folio_test_hwpoison()
Date: Tue, 25 Apr 2023 15:47:24 -0700	[thread overview]
Message-ID: <ZEhYfHePaLpoUhbp@bombadil.infradead.org> (raw)
In-Reply-To: <20230425110025.7tq5vdr2jfom2zdh@localhost>

On Tue, Apr 25, 2023 at 01:00:25PM +0200, Pankaj Raghav wrote:
> On Fri, Apr 21, 2023 at 11:42:53PM +0100, Matthew Wilcox wrote:
> > On Fri, Apr 21, 2023 at 02:43:54PM -0700, Luis Chamberlain wrote:
> > > The PageHWPoison() call can be converted over to the respective folio call
> > > folio_test_hwpoison(). This introduces no functional changes.
> > 
> > Um, no.  Nobody should use folio_test_hwpoison(), it's a nonsense.
> > 
> > Individual pages are hwpoisoned.  You're only testing the head page
> > if you use folio_test_hwpoison().  There's folio_has_hwpoisoned() to
> > test if _any_ page in the folio is poisoned.  But blindly converting
> > PageHWPoison to folio_test_hwpoison() is wrong.
> 
> I see a pattern in shmem.c where first the head is tested and for large
> folios, any of pages in the folio is tested for poison flag. Should we
> factor it out as a helper in shmem.c and use it here?
> 
> static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos,
> ...
> 	if (folio_test_hwpoison(folio) ||
> 	    (folio_test_large(folio) &&
> 	     folio_test_has_hwpoisoned(folio))) {
> 	..

Hugh's commit 72887c976a7c9e ("shmem: minor fixes to splice-read
implementation") is on point about this :

  "Perhaps that ugliness can be improved at the mm end later"

So how about we put some lipstick on this guy now (notice right above it
a similar compound page check for is_page_hwpoison()):

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 1c68d67b832f..6a4a571dbe50 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
diff --git a/mm/shmem.c b/mm/shmem.c
index ef7ad684f4fb..b7f47f6b75d5 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3013,9 +3013,7 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos,
 		if (folio) {
 			folio_unlock(folio);
 
-			if (folio_test_hwpoison(folio) ||
-			    (folio_test_large(folio) &&
-			     folio_test_has_hwpoisoned(folio))) {
+			if (is_folio_hwpoison(folio)) {
 				error = -EIO;
 				break;
 			}

  reply	other threads:[~2023-04-25 22:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21 21:43 [RFC 0/8] shmem: add support for blocksize > PAGE_SIZE Luis Chamberlain
2023-04-21 21:43 ` [RFC 1/8] shmem: replace BLOCKS_PER_PAGE with PAGE_SECTORS Luis Chamberlain
2023-04-21 21:43 ` [RFC 2/8] shmem: convert to use folio_test_hwpoison() Luis Chamberlain
2023-04-21 22:42   ` Matthew Wilcox
2023-04-22  3:05     ` Luis Chamberlain
2023-04-24 21:17       ` Yang Shi
2023-04-24 21:36         ` Matthew Wilcox
2023-04-24 23:05           ` Yang Shi
     [not found]     ` <CGME20230425110913eucas1p22cf9d4c7401881999adb12134b985273@eucas1p2.samsung.com>
2023-04-25 11:00       ` Pankaj Raghav
2023-04-25 22:47         ` Luis Chamberlain [this message]
2023-04-26  7:43           ` Luis Chamberlain
2023-04-21 21:43 ` [RFC 3/8] shmem: account for high order folios Luis Chamberlain
2023-04-21 22:46   ` Matthew Wilcox
2023-04-21 21:43 ` [RFC 4/8] shmem: add helpers to get block size Luis Chamberlain
2023-04-21 22:49   ` Matthew Wilcox
2023-04-21 21:43 ` [RFC 5/8] shmem: account for larger blocks sizes for shmem_default_max_blocks() Luis Chamberlain
2023-04-21 21:43 ` [RFC 6/8] shmem: consider block size in shmem_default_max_inodes() Luis Chamberlain
2023-04-21 21:43 ` [RFC 7/8] shmem: add high order page support Luis Chamberlain
2023-04-21 21:44 ` [RFC 8/8] shmem: add support to customize block size on multiple PAGE_SIZE Luis Chamberlain
2023-04-22  5:10   ` Jane Chu

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=ZEhYfHePaLpoUhbp@bombadil.infradead.org \
    --to=mcgrof@kernel.org \
    --cc=a.manzanares@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=da.gomez@samsung.com \
    --cc=dave@stgolabs.net \
    --cc=djwong@kernel.org \
    --cc=hare@suse.de \
    --cc=hughd@google.com \
    --cc=kbusch@kernel.org \
    --cc=keescook@chromium.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=p.raghav@samsung.com \
    --cc=patches@lists.linux.dev \
    --cc=willy@infradead.org \
    --cc=yosryahmed@google.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;
as well as URLs for NNTP newsgroup(s).