* [PATCH] splice: pass a poll key when waking pipe readers and writers
@ 2026-09-16 8:37 Breno Leitao
2026-09-16 10:57 ` Oleg Nesterov
0 siblings, 1 reply; 3+ messages in thread
From: Breno Leitao @ 2026-09-16 8:37 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara
Cc: mjguzik, oleg, linux-fsdevel, linux-kernel, kernel-team, Breno Leitao
wakeup_pipe_readers() and wakeup_pipe_writers() wake the pipe wait queues
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 pipe is woken, whether or not it asked for the
event that occurred.
anon_pipe_read() and anon_pipe_write() already pass EPOLLIN | EPOLLRDNORM
and EPOLLOUT | EPOLLWRNORM when waking the same wait queues. Do the same
here.
This is not visible in common pipe use: ordinary pipelines move data with
read()/write(), which already passes the key.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
fs/splice.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/splice.c b/fs/splice.c
index 9d8f63e2fd1ab..c048183215343 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -179,7 +179,8 @@ static void wakeup_pipe_readers(struct pipe_inode_info *pipe)
{
smp_mb();
if (waitqueue_active(&pipe->rd_wait))
- wake_up_interruptible(&pipe->rd_wait);
+ wake_up_interruptible_poll(&pipe->rd_wait,
+ EPOLLIN | EPOLLRDNORM);
kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
}
@@ -415,7 +416,8 @@ static void wakeup_pipe_writers(struct pipe_inode_info *pipe)
{
smp_mb();
if (waitqueue_active(&pipe->wr_wait))
- wake_up_interruptible(&pipe->wr_wait);
+ wake_up_interruptible_poll(&pipe->wr_wait,
+ EPOLLOUT | EPOLLWRNORM);
kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
}
---
base-commit: 587858367581b9c55c3690f4e63382ad622719d4
change-id: 20260915-b4-splice-poll-key-bc7d5d0d0f68
Best regards,
--
Breno Leitao <leitao@debian.org>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] splice: pass a poll key when waking pipe readers and writers
2026-09-16 8:37 [PATCH] splice: pass a poll key when waking pipe readers and writers Breno Leitao
@ 2026-09-16 10:57 ` Oleg Nesterov
2026-09-16 11:31 ` Breno Leitao
0 siblings, 1 reply; 3+ messages in thread
From: Oleg Nesterov @ 2026-09-16 10:57 UTC (permalink / raw)
To: Breno Leitao
Cc: Alexander Viro, Christian Brauner, Jan Kara, mjguzik,
linux-fsdevel, linux-kernel, kernel-team
On 09/16, Breno Leitao wrote:
>
> --- a/fs/splice.c
> +++ b/fs/splice.c
> @@ -179,7 +179,8 @@ static void wakeup_pipe_readers(struct pipe_inode_info *pipe)
> {
> smp_mb();
> if (waitqueue_active(&pipe->rd_wait))
> - wake_up_interruptible(&pipe->rd_wait);
> + wake_up_interruptible_poll(&pipe->rd_wait,
> + EPOLLIN | EPOLLRDNORM);
> kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
> }
>
> @@ -415,7 +416,8 @@ static void wakeup_pipe_writers(struct pipe_inode_info *pipe)
> {
> smp_mb();
> if (waitqueue_active(&pipe->wr_wait))
> - wake_up_interruptible(&pipe->wr_wait);
> + wake_up_interruptible_poll(&pipe->wr_wait,
> + EPOLLOUT | EPOLLWRNORM);
> kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
> }
Acked-by: Oleg Nesterov <oleg@redhat.com>
While at it... I think they both should use wq_has_sleeper().
If you agree, feel free to send V2 with this additional change.
Or I will send this trivial cleanup on top of your patch.
Oleg.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] splice: pass a poll key when waking pipe readers and writers
2026-09-16 10:57 ` Oleg Nesterov
@ 2026-09-16 11:31 ` Breno Leitao
0 siblings, 0 replies; 3+ messages in thread
From: Breno Leitao @ 2026-09-16 11:31 UTC (permalink / raw)
To: Oleg Nesterov
Cc: Alexander Viro, Christian Brauner, Jan Kara, mjguzik,
linux-fsdevel, linux-kernel, kernel-team
On Wed, Sep 16, 2026 at 12:57:13PM +0200, Oleg Nesterov wrote:
> While at it... I think they both should use wq_has_sleeper().
Good point, thanks!
> If you agree, feel free to send V2 with this additional change.
Sure, let's wait a bit more before I send v2, but I've got this fix updated
already to the following change:
diff --git a/fs/splice.c b/fs/splice.c
index 9d8f63e2fd1ab..65f9090c3438c 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -177,9 +177,9 @@ static const struct pipe_buf_operations user_page_pipe_buf_ops = {
static void wakeup_pipe_readers(struct pipe_inode_info *pipe)
{
- smp_mb();
- if (waitqueue_active(&pipe->rd_wait))
- wake_up_interruptible(&pipe->rd_wait);
+ if (wq_has_sleeper(&pipe->rd_wait))
+ wake_up_interruptible_poll(&pipe->rd_wait,
+ EPOLLIN | EPOLLRDNORM);
kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
}
@@ -413,9 +413,9 @@ EXPORT_SYMBOL(nosteal_pipe_buf_ops);
static void wakeup_pipe_writers(struct pipe_inode_info *pipe)
{
- smp_mb();
- if (waitqueue_active(&pipe->wr_wait))
- wake_up_interruptible(&pipe->wr_wait);
+ if (wq_has_sleeper(&pipe->wr_wait))
+ wake_up_interruptible_poll(&pipe->wr_wait,
+ EPOLLOUT | EPOLLWRNORM);
kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
}
Thanks for the quick review,
--breno
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-16 11:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 8:37 [PATCH] splice: pass a poll key when waking pipe readers and writers Breno Leitao
2026-09-16 10:57 ` Oleg Nesterov
2026-09-16 11:31 ` Breno Leitao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®