diff mbox series

[for-next,1/7] io_uring: use user visible tail in io_uring_poll()

Message ID 228ffcbf30ba98856f66ffdb9a6a60ead1dd96c0.1674484266.git.asml.silence@gmail.com (mailing list archive)
State New
Headers show
Series normal tw optimisation + refactoring | expand

Commit Message

Pavel Begunkov Jan. 23, 2023, 2:37 p.m. UTC
We return POLLIN from io_uring_poll() depending on whether there are
CQEs for the userspace, and so we should use the user visible tail
pointer instead of a transient cached value.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/io_uring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jens Axboe Jan. 23, 2023, 6:25 p.m. UTC | #1
On 1/23/23 7:37 AM, Pavel Begunkov wrote:
> We return POLLIN from io_uring_poll() depending on whether there are
> CQEs for the userspace, and so we should use the user visible tail
> pointer instead of a transient cached value.

Should we mark this one for stable as well?
Pavel Begunkov Jan. 23, 2023, 8:56 p.m. UTC | #2
On 1/23/23 18:25, Jens Axboe wrote:
> On 1/23/23 7:37 AM, Pavel Begunkov wrote:
>> We return POLLIN from io_uring_poll() depending on whether there are
>> CQEs for the userspace, and so we should use the user visible tail
>> pointer instead of a transient cached value.
> 
> Should we mark this one for stable as well?
Yeah, we can. It makes it to overestimate the number of ready CQEs
and causes spurious POLLINs, but should be extremely rare and happen
only on queue (but not wq wake up).
Jens Axboe Jan. 23, 2023, 9:09 p.m. UTC | #3
On 1/23/23 1:56 PM, Pavel Begunkov wrote:
> On 1/23/23 18:25, Jens Axboe wrote:
>> On 1/23/23 7:37 AM, Pavel Begunkov wrote:
>>> We return POLLIN from io_uring_poll() depending on whether there are
>>> CQEs for the userspace, and so we should use the user visible tail
>>> pointer instead of a transient cached value.
>>
>> Should we mark this one for stable as well?
> Yeah, we can. It makes it to overestimate the number of ready CQEs
> and causes spurious POLLINs, but should be extremely rare and happen
> only on queue (but not wq wake up).

Right, it's not critical, but we may as well.
diff mbox series

Patch

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index aef30d265a13..c42c1124ad5c 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -2888,7 +2888,7 @@  static __poll_t io_uring_poll(struct file *file, poll_table *wait)
 	 * pushes them to do the flush.
 	 */
 
-	if (io_cqring_events(ctx) || io_has_work(ctx))
+	if (__io_cqring_events_user(ctx) || io_has_work(ctx))
 		mask |= EPOLLIN | EPOLLRDNORM;
 
 	return mask;