From: Breno Leitao <leitao@debian.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Christian Brauner <brauner@kernel.org>,
Mateusz Guzik <mjguzik@gmail.com>, Jens Axboe <axboe@kernel.dk>,
Pavel Begunkov <asml.silence@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Jan Kara <jack@suse.cz>, Alexey Gladkov <legion@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
io-uring@vger.kernel.org
Subject: Re: [PATCH v3 1/1] pipe: only enable the extra wake_up(rd_wait) for edge-triggered consumers
Date: Thu, 30 Jul 2026 07:26:35 -0700 [thread overview]
Message-ID: <amteY30qxRuPzFh3@gmail.com> (raw)
In-Reply-To: <amtbxpqJ3pZwyT8D@redhat.com>
On Thu, Jul 30, 2026 at 04:12:22PM +0200, Oleg Nesterov wrote:
> pipe_poll() unconditionally sets poll_usage on the first call, forcing
> anon_pipe_write() to wake up readers on every write even if the pipe was
> not empty. But this is only needed for edge-triggered consumers: epoll
> with EPOLLET and io_uring without (unsupported) IORING_POLL_ADD_LEVEL.
> poll() and select() users pay for it for no reason.
>
> Rename ->poll_usage to ->poll_et to make the purpose clearer, update the
> comments to explain that io_uring depends on the "nasty semantics" too,
> and change pipe_poll() to set ->poll_et only if wait->_key & EPOLLET is
> true; this check should catch both users.
This look great at first sight, thanks!
> @@ -760,9 +759,11 @@ pipe_poll(struct file *filp, poll_table *wait)
> struct pipe_inode_info *pipe = filp->private_data;
> union pipe_index idx;
>
> - /* Epoll has some historical nasty semantics, this enables them */
> - if (unlikely(!READ_ONCE(pipe->poll_usage)))
> - WRITE_ONCE(pipe->poll_usage, true);
> + /* Enable edge-triggered (epoll, io_uring) per-write wakeups */
> + if ((filp->f_mode & FMODE_READ) &&
> + wait && (wait->_key & EPOLLET) &&
> + unlikely(!READ_ONCE(pipe->poll_et)))
> + WRITE_ONCE(pipe->poll_et, true);
Can I ask you to factor this out set code, and comment this nasty
semantics in the function and why we need to do it?
Tha would help to make this corner case more visible for readers, other
than hidden on commit messages.
Thanks,
--breno
next prev parent reply other threads:[~2026-07-30 14:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 14:11 [PATCH v3 0/1] pipe: only enable the extra wake_up(rd_wait) for edge-triggered consumers Oleg Nesterov
2026-07-30 14:12 ` [PATCH v3 1/1] " Oleg Nesterov
2026-07-30 14:26 ` Breno Leitao [this message]
2026-07-30 14:38 ` Oleg Nesterov
2026-07-30 16:36 ` [PATCH v3 0/1] " Linus Torvalds
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=amteY30qxRuPzFh3@gmail.com \
--to=leitao@debian.org \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=io-uring@vger.kernel.org \
--cc=jack@suse.cz \
--cc=legion@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjguzik@gmail.com \
--cc=oleg@redhat.com \
--cc=torvalds@linux-foundation.org \
--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