Skip to contentSkip to conversation

selftests/epoll: add a regression test for pipe->poll_usage

PATCH Applied Oleg Nesterov 2 participants 2 messages Jul 29 – Aug 13 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 selftests/epoll: add a regression test for pipe->poll_usage

pipe->poll_usage was added to ensure that edge-triggered epoll consumers get a wakeup on every write, even if the pipe was already non-empty. However, none of the existing epoll_wakeup_test cases cover this; the test suite passes even with WRITE_ONCE(pipe->poll_usage, true) removed.

Add a test that writes twice to a pipe and verifies that epoll_wait with EPOLLET reports data each time. This covers the pipe-specific per-write wakeup behavior that edge-triggered consumers depend on.

---
 .../filesystems/epoll/epoll_wakeup_test.c     | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c +23 -0
index f6f1a7ff01b0..81a994943e12 100644
@@ -3538,4 +3538,27 @@ TEST(epoll65)
 	close(ctx.efd[1]);
 }
 
+TEST(epoll66)
+{
+	struct epoll_event event;
+	int pfd[2], efd;
+
+	ASSERT_EQ(pipe(pfd), 0);
+
+	efd = epoll_create1(0);
+	ASSERT_GE(efd, 0);
+
+	event.events = EPOLLIN | EPOLLET;
+	ASSERT_EQ(epoll_ctl(efd, EPOLL_CTL_ADD, pfd[0], &event), 0);
+
+	for (int i = 0; i < 2; ++i) {
+		ASSERT_EQ(write(pfd[1], "", 1), 1);
+		EXPECT_EQ(epoll_wait(efd, &event, 1, 0), 1);
+	}
+
+	close(pfd[0]);
+	close(pfd[1]);
+	close(efd);
+}
+
 TEST_HARNESS_MAIN
Signature · 1 line
2.52.0
#1 lore raw
Quoted 1 line · Oleg Nesterov

selftests/epoll: add a regression test for pipe->poll_usage

Applied to the vfs-7.3.misc branch of the vfs/vfs.git tree. Patches in the vfs-7.3.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.3.misc

[1/1] selftests/epoll: add a regression test for pipe->poll_usage

      https://git.kernel.org/vfs/vfs/c/ab018b7733bd