diff options
author | Jens Axboe <axboe@kernel.dk> | 2023-02-25 22:53:53 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2023-02-26 06:10:13 +0300 |
commit | c16bda37594f83147b167d381d54c010024efecf (patch) | |
tree | 101f34ed727c287b7bdcfb2830dc12a90d21f018 /io_uring/poll.h | |
parent | 7605c43d67face310b4b87dee1a28bc0c8cd8c0f (diff) | |
download | linux-c16bda37594f83147b167d381d54c010024efecf.tar.xz |
io_uring/poll: allow some retries for poll triggering spuriously
If we get woken spuriously when polling and fail the operation with
-EAGAIN again, then we generally only allow polling again if data
had been transferred at some point. This is indicated with
REQ_F_PARTIAL_IO. However, if the spurious poll triggers when the socket
was originally empty, then we haven't transferred data yet and we will
fail the poll re-arm. This either punts the socket to io-wq if it's
blocking, or it fails the request with -EAGAIN if not. Neither condition
is desirable, as the former will slow things down, while the latter
will make the application confused.
We want to ensure that a repeated poll trigger doesn't lead to infinite
work making no progress, that's what the REQ_F_PARTIAL_IO check was
for. But it doesn't protect against a loop post the first receive, and
it's unnecessarily strict if we started out with an empty socket.
Add a somewhat random retry count, just to put an upper limit on the
potential number of retries that will be done. This should be high enough
that we won't really hit it in practice, unless something needs to be
aborted anyway.
Cc: stable@vger.kernel.org # v5.10+
Link: https://github.com/axboe/liburing/issues/364
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/poll.h')
-rw-r--r-- | io_uring/poll.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/io_uring/poll.h b/io_uring/poll.h index 5f3bae50fc81..b2393b403a2c 100644 --- a/io_uring/poll.h +++ b/io_uring/poll.h @@ -12,6 +12,7 @@ struct io_poll { struct file *file; struct wait_queue_head *head; __poll_t events; + int retries; struct wait_queue_entry wait; }; |