[PATCH] pipe: pass a poll key when waking writers after a resize

From: Breno Leitao

Date: Wed Sep 16 2026 - 12:08:07 EST


pipe_resize_ring() wakes pipe->wr_wait with a NULL key. ep_poll_callback()
and pollwake() only filter on the registered event mask when a key is
supplied, so every epoll, poll() and select() waiter on the write queue is
woken, whether or not it asked for the event that occurred.

The event is the one the comment above the wakeup already names: more room
for writers. anon_pipe_write() passes EPOLLOUT | EPOLLWRNORM when waking
the same queue; do the same here. Writers blocked in
wait_event_interruptible_exclusive() are unaffected, as
autoremove_wake_function() ignores the key.

Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>
---
This is the last NULL-key wakeup on a pipe wait queue that signals a data
or space event. The remaining ones in fs/pipe.c are all hangup broadcasts
(pipe_release(), wake_up_partner(), the fifo_open() error paths), where a
key would make no difference: poll, select and epoll all add
EPOLLERR | EPOLLHUP to the registered mask unconditionally, so those
wakeups can never be filtered out.

To: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
To: Christian Brauner <brauner@xxxxxxxxxx>
To: Jan Kara <jack@xxxxxxx>
Cc: linux-fsdevel@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: mjguzik@xxxxxxxxx
To: oleg@xxxxxxxxxx
---
fs/pipe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/pipe.c b/fs/pipe.c
index 292425a834dd5..5791db016e242 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1433,7 +1433,7 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
spin_unlock_irq(&pipe->rd_wait.lock);

/* This might have made more room for writers */
- wake_up_interruptible(&pipe->wr_wait);
+ wake_up_interruptible_poll(&pipe->wr_wait, EPOLLOUT | EPOLLWRNORM);
return 0;
}


---
base-commit: 587858367581b9c55c3690f4e63382ad622719d4
change-id: 20260916-pipe-resize-poll-key-017a2180d481

Best regards,
--
Breno Leitao <leitao@xxxxxxxxxx>