From: Andrew Morton <akpm@linux-foundation.org>
To: Kurt Lin <lylin1023@gmail.com>
Cc: linux-mm@kvack.org, "Andrew Morton" <akpm@linux-foundation.org>,
"Miaohe Lin" <linmiaohe@huawei.com>,
"Naoya Horiguchi" <nao.horiguchi@gmail.com>,
"David Hildenbrand" <david@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Mike Rapoport" <rppt@kernel.org>,
"Michal Hocko" <mhocko@suse.com>, "Shuah Khan" <shuah@kernel.org>,
"Muhammad Usama Anjum" <usama.anjum@arm.com>,
"Amir Goldstein" <amir73il@gmail.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"German Maglione" <gmaglione@redhat.com>,
"Miklos Szeredi" <miklos@szeredi.hu>,
"Ryusuke Konishi" <konishi.ryusuke@gmail.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Vivek Goyal" <vgoyal@redhat.com>
Subject: [PATCH 1/9] selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache
Date: Fri, 27 Nov 2026 22:51:56 -0800 [thread overview]
Message-ID: <1c93b263b19d4465899bb81efd62bcb3.1@linux-foundation.org> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4207 bytes --]
From: Andrew Morton <akpm@linux-foundation.org>
Subject: selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache
Date: Mon, 23 Nov 2026 23:18:44 -0800
MADV_HWPOISON on a dirty page-cache page records -EIO in the mapping. The
test currently requires close() to succeed but never checks whether the
error was reported. Filesystems with ->flush() may return EIO from
close(), while those without it can leave the error unnoticed.
Require fsync() to return EIO after hard poisoning. It consumes the
mapping error before close(), allowing the NFS skip to go. The clean and
dirty page-cache cases also skip tmpfs, ramfs and hugetlbfs because they
have no backing store from which to reread a poisoned clean page.
With the complete selftest patch stack under x86_64 QEMU, ext4, FUSE and
NFSv4.2 reported 10 passes; NILFS2 reported 9 passes and 1 skip. The FUSE
server used for this test was a minimal server, not virtiofs.
Fixes: d51b5076c746 ("selftests/mm: add memory failure dirty pagecache test")
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Kurt Lin <lylin1023@gmail.com>
Closes: https://lore.kernel.org/20261123-memory-failure-fuse-skip-v1-1-19dcbda6e2e8@gmail.com
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Muhammad Usama Anjum <usama.anjum@arm.com>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Eugenio Pérez <eperezma@redhat.com>
Cc: German Maglione <gmaglione@redhat.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
tools/testing/selftests/mm/memory-failure.c | 38 ++++++++++++++----
1 file changed, 30 insertions(+), 8 deletions(-)
--- a/tools/testing/selftests/mm/memory-failure.c~selftests-mm-check-that-fsync-reports-hard-poisoned-dirty-page-cache
+++ a/tools/testing/selftests/mm/memory-failure.c
@@ -300,6 +300,29 @@ static int get_fs_type(int fd)
return ret ? 0 : (int)fs.f_type;
}
+/*
+ * The page-cache tests need a filesystem which keeps its data on backing
+ * store. When a clean page is poisoned the kernel drops it and the data is
+ * read back in. When a dirty page is poisoned the data is lost, and the
+ * kernel records -EIO in the mapping for fsync() to report.
+ *
+ * tmpfs and ramfs keep their data only in the page cache. The poisoned
+ * page cannot be dropped and read back, and their fsync() does nothing, so
+ * neither expectation holds. hugetlbfs is the same, and it also poisons a
+ * whole huge page. shmem has its own tests below.
+ */
+static bool fs_has_backing_store(int fs_type)
+{
+ switch ((unsigned int)fs_type) {
+ case 0:
+ case TMPFS_MAGIC:
+ case RAMFS_MAGIC:
+ case HUGETLBFS_MAGIC:
+ return false;
+ }
+ return true;
+}
+
TEST_F(memory_failure, clean_pagecache)
{
int fd;
@@ -311,7 +334,7 @@ TEST_F(memory_failure, clean_pagecache)
if (fd < 0)
SKIP(return, "failed to open test file.\n");
fs_type = get_fs_type(fd);
- if (!fs_type || fs_type == TMPFS_MAGIC) {
+ if (!fs_has_backing_store(fs_type)) {
close(fd);
SKIP(return, "unsupported filesystem :%x\n", fs_type);
}
@@ -353,13 +376,7 @@ TEST_F(memory_failure, dirty_pagecache)
if (fd < 0)
SKIP(return, "failed to open test file.\n");
fs_type = get_fs_type(fd);
- /*
- * MADV_HARD poisoning of dirty page-cache data records an expected
- * -EIO in the file mapping. NFS reports this error on close(), so
- * skip this variant.
- */
- if (!fs_type || fs_type == TMPFS_MAGIC ||
- (fs_type == NFS_SUPER_MAGIC && variant->type == MADV_HARD)) {
+ if (!fs_has_backing_store(fs_type)) {
close(fd);
SKIP(return, "unsupported filesystem :%x\n", fs_type);
}
@@ -386,6 +403,11 @@ TEST_F(memory_failure, dirty_pagecache)
ASSERT_EQ(munmap(addr, self->page_size), 0);
+ if (variant->type == MADV_HARD) {
+ ASSERT_EQ(fsync(fd), -1);
+ ASSERT_EQ(errno, EIO);
+ }
+
ASSERT_EQ(close(fd), 0);
}
_
next reply other threads:[~2026-11-28 6:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 6:51 Andrew Morton [this message]
2026-11-28 6:51 ` [PATCH 2/9] selftests/mm/memory-failure: truncate poisoned FUSE page-cache before teardown Andrew Morton
2026-11-28 6:52 ` [PATCH 3/9] selftests/mm/memory-failure: skip poisoned dirty page-cache on NILFS2 Andrew Morton
2026-11-28 6:52 ` [PATCH 4/9] selftest/mm/memory-failure: keep page-cache files linked until cleanup Andrew Morton
2026-11-28 6:52 ` [PATCH 5/9] selftests/mm/memory-failure: skip hard dirty page-cache test on CephFS Andrew Morton
2026-11-28 6:52 ` [PATCH 6/9] selftests/mm/memory-failure: close dirty page-cache files before unlinking them Andrew Morton
2026-11-28 6:52 ` [PATCH 7/9] selftests/mm/memory-failure: extend page-cache test files with pwrite() Andrew Morton
2026-11-28 6:52 ` [PATCH 8/9] selftests/mm/memory-failure: write the whole page-cache test file for OMFS Andrew Morton
2026-11-28 6:52 ` [PATCH 9/9] selftests/mm/memory-failure: accept EIO from close after poisoning dirty data Andrew Morton
2026-11-28 18:36 ` [PATCH 1/9] selftests/mm/memory-failure: check that fsync() reports hard-poisoned dirty page-cache Kurt Lin
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=1c93b263b19d4465899bb81efd62bcb3.1@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=amir73il@gmail.com \
--cc=david@kernel.org \
--cc=eperezma@redhat.com \
--cc=gmaglione@redhat.com \
--cc=konishi.ryusuke@gmail.com \
--cc=liam@infradead.org \
--cc=linmiaohe@huawei.com \
--cc=linux-mm@kvack.org \
--cc=lylin1023@gmail.com \
--cc=mhocko@suse.com \
--cc=miklos@szeredi.hu \
--cc=nao.horiguchi@gmail.com \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=stefanha@redhat.com \
--cc=usama.anjum@arm.com \
--cc=vbabka@kernel.org \
--cc=vgoyal@redhat.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