mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	 Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	 kernel-team@meta.com, Breno Leitao <leitao@debian.org>,
	mjguzik@gmail.com,  oleg@redhat.com
Subject: [PATCH] pipe: pass a poll key when waking writers after a resize
Date: Wed, 16 Sep 2026 08:57:14 -0700	[thread overview]
Message-ID: <20260916-pipe-resize-poll-key-v1-1-0f8f04f7dd5e@debian.org> (raw)

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@debian.org>
---
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@zeniv.linux.org.uk>
To: Christian Brauner <brauner@kernel.org>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: mjguzik@gmail.com
To: oleg@redhat.com
---
 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@debian.org>


             reply	other threads:[~2026-09-16 16:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 15:57 Breno Leitao [this message]
2026-09-25 14:44 ` Christian Brauner

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=20260916-pipe-resize-poll-key-v1-1-0f8f04f7dd5e@debian.org \
    --to=leitao@debian.org \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=kernel-team@meta.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjguzik@gmail.com \
    --cc=oleg@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®