public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: flush overflowed CQ events in the io_uring_poll()
@ 2020-02-07 12:18 Stefano Garzarella
  2020-02-07 16:12 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Stefano Garzarella @ 2020-02-07 12:18 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, linux-fsdevel, Alexander Viro, io-uring

In io_uring_poll() we must flush overflowed CQ events before to
check if there are CQ events available, to avoid missing events.

We call the io_cqring_events() that checks and flushes any overflow
and returns the number of CQ events available.

We can avoid taking the 'uring_lock' since the flush is already
protected by 'completion_lock'.

Signed-off-by: Stefano Garzarella <[email protected]>
---
 fs/io_uring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 77f22c3da30f..02e77e86abaf 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -6301,7 +6301,7 @@ static __poll_t io_uring_poll(struct file *file, poll_table *wait)
 	if (READ_ONCE(ctx->rings->sq.tail) - ctx->cached_sq_head !=
 	    ctx->rings->sq_ring_entries)
 		mask |= EPOLLOUT | EPOLLWRNORM;
-	if (READ_ONCE(ctx->rings->cq.head) != ctx->cached_cq_tail)
+	if (io_cqring_events(ctx, false))
 		mask |= EPOLLIN | EPOLLRDNORM;
 
 	return mask;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] io_uring: flush overflowed CQ events in the io_uring_poll()
  2020-02-07 12:18 [PATCH] io_uring: flush overflowed CQ events in the io_uring_poll() Stefano Garzarella
@ 2020-02-07 16:12 ` Jens Axboe
  2020-02-07 16:38   ` Stefano Garzarella
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2020-02-07 16:12 UTC (permalink / raw)
  To: Stefano Garzarella; +Cc: linux-kernel, linux-fsdevel, Alexander Viro, io-uring

On 2/7/20 5:18 AM, Stefano Garzarella wrote:
> In io_uring_poll() we must flush overflowed CQ events before to
> check if there are CQ events available, to avoid missing events.
> 
> We call the io_cqring_events() that checks and flushes any overflow
> and returns the number of CQ events available.
> 
> We can avoid taking the 'uring_lock' since the flush is already
> protected by 'completion_lock'.

Thanks, applied. I dropped that last sentence, as a) it doesn't
really matter, and b) we may very well already have it held here
if someone is doing a poll on the io_uring fd itself.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] io_uring: flush overflowed CQ events in the io_uring_poll()
  2020-02-07 16:12 ` Jens Axboe
@ 2020-02-07 16:38   ` Stefano Garzarella
  0 siblings, 0 replies; 3+ messages in thread
From: Stefano Garzarella @ 2020-02-07 16:38 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, linux-fsdevel, Alexander Viro, io-uring

On Fri, Feb 07, 2020 at 09:12:39AM -0700, Jens Axboe wrote:
> On 2/7/20 5:18 AM, Stefano Garzarella wrote:
> > In io_uring_poll() we must flush overflowed CQ events before to
> > check if there are CQ events available, to avoid missing events.
> > 
> > We call the io_cqring_events() that checks and flushes any overflow
> > and returns the number of CQ events available.
> > 
> > We can avoid taking the 'uring_lock' since the flush is already
> > protected by 'completion_lock'.
> 
> Thanks, applied. I dropped that last sentence, as a) it doesn't
> really matter, and b) we may very well already have it held here
> if someone is doing a poll on the io_uring fd itself.

Sure, indeed I was undecided whether to put it after the three dashes
as a response to your yesterday's request.

Thanks,
Stefano


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-07 16:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-07 12:18 [PATCH] io_uring: flush overflowed CQ events in the io_uring_poll() Stefano Garzarella
2020-02-07 16:12 ` Jens Axboe
2020-02-07 16:38   ` Stefano Garzarella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox