Patch "io_uring/poll: allow some retries for poll triggering spuriously" has been added to the 6.2-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    io_uring/poll: allow some retries for poll triggering spuriously

to the 6.2-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     io_uring-poll-allow-some-retries-for-poll-triggering-spuriously.patch
and it can be found in the queue-6.2 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From c16bda37594f83147b167d381d54c010024efecf Mon Sep 17 00:00:00 2001
From: Jens Axboe <axboe@xxxxxxxxx>
Date: Sat, 25 Feb 2023 12:53:53 -0700
Subject: io_uring/poll: allow some retries for poll triggering spuriously

From: Jens Axboe <axboe@xxxxxxxxx>

commit c16bda37594f83147b167d381d54c010024efecf upstream.

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@xxxxxxxxxxxxxxx # v5.10+
Link: https://github.com/axboe/liburing/issues/364
Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 io_uring/poll.c |   14 ++++++++++++--
 io_uring/poll.h |    1 +
 2 files changed, 13 insertions(+), 2 deletions(-)

--- a/io_uring/poll.c
+++ b/io_uring/poll.c
@@ -650,6 +650,14 @@ static void io_async_queue_proc(struct f
 	__io_queue_proc(&apoll->poll, pt, head, &apoll->double_poll);
 }
 
+/*
+ * We can't reliably detect loops in repeated poll triggers and issue
+ * subsequently failing. But rather than fail these immediately, allow a
+ * certain amount of retries before we give up. Given that this condition
+ * should _rarely_ trigger even once, we should be fine with a larger value.
+ */
+#define APOLL_MAX_RETRY		128
+
 static struct async_poll *io_req_alloc_apoll(struct io_kiocb *req,
 					     unsigned issue_flags)
 {
@@ -665,14 +673,18 @@ static struct async_poll *io_req_alloc_a
 		if (entry == NULL)
 			goto alloc_apoll;
 		apoll = container_of(entry, struct async_poll, cache);
+		apoll->poll.retries = APOLL_MAX_RETRY;
 	} else {
 alloc_apoll:
 		apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC);
 		if (unlikely(!apoll))
 			return NULL;
+		apoll->poll.retries = APOLL_MAX_RETRY;
 	}
 	apoll->double_poll = NULL;
 	req->apoll = apoll;
+	if (unlikely(!--apoll->poll.retries))
+		return NULL;
 	return apoll;
 }
 
@@ -694,8 +706,6 @@ int io_arm_poll_handler(struct io_kiocb
 		return IO_APOLL_ABORTED;
 	if (!file_can_poll(req->file))
 		return IO_APOLL_ABORTED;
-	if ((req->flags & (REQ_F_POLLED|REQ_F_PARTIAL_IO)) == REQ_F_POLLED)
-		return IO_APOLL_ABORTED;
 	if (!(req->flags & REQ_F_APOLL_MULTISHOT))
 		mask |= EPOLLONESHOT;
 
--- 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;
 };
 


Patches currently in stable-queue which might be from axboe@xxxxxxxxx are

queue-6.2/io_uring-handle-tif_notify_resume-when-checking-for-task_work.patch
queue-6.2/block-don-t-allow-multiple-bios-for-iocb_nowait-issue.patch
queue-6.2/sbitmap-correct-wake_batch-recalculation-to-avoid-po.patch
queue-6.2/blk-mq-avoid-sleep-in-blk_mq_alloc_request_hctx.patch
queue-6.2/io_uring-add-reschedule-point-to-handle_tw_list.patch
queue-6.2/ublk_drv-remove-nr_aborted_queues-from-ublk_device.patch
queue-6.2/io_uring-remove-msg_nosignal-from-recvmsg.patch
queue-6.2/blk-mq-fix-potential-io-hung-for-shared-sbitmap-per-.patch
queue-6.2/blk-mq-wait-on-correct-sbitmap_queue-in-blk_mq_mark_.patch
queue-6.2/block-clear-bio-bi_bdev-when-putting-a-bio-back-in-the-cache.patch
queue-6.2/io_uring-fix-fget-leak-when-fs-don-t-support-nowait-buffered-read.patch
queue-6.2/ublk_drv-don-t-probe-partitions-if-the-ubq-daemon-is.patch
queue-6.2/trace-blktrace-fix-memory-leak-with-using-debugfs_lo.patch
queue-6.2/io_uring-audit-don-t-log-ioring_op_madvise.patch
queue-6.2/io_uring-rsrc-disallow-multi-source-reg-buffers.patch
queue-6.2/x86-fpu-don-t-set-tif_need_fpu_load-for-pf_io_worker.patch
queue-6.2/io_uring-replace-0-length-array-with-flexible-array.patch
queue-6.2/blk-cgroup-dropping-parent-refcount-after-pd_free_fn.patch
queue-6.2/block-be-a-bit-more-careful-in-checking-for-null-bdev-while-polling.patch
queue-6.2/block-use-proper-return-value-from-bio_failfast.patch
queue-6.2/block-fix-io-statistics-for-cgroup-in-throttle-path.patch
queue-6.2/block-ublk-check-io-buffer-based-on-flag-need_get_da.patch
queue-6.2/io_uring-use-user-visible-tail-in-io_uring_poll.patch
queue-6.2/blk-cgroup-synchronize-pd_free_fn-from-blkg_free_wor.patch
queue-6.2/sbitmap-remove-redundant-check-in-__sbitmap_queue_ge.patch
queue-6.2/io_uring-poll-allow-some-retries-for-poll-triggering-spuriously.patch
queue-6.2/block-sync-mixed-merged-request-s-failfast-with-1st-.patch
queue-6.2/blk-mq-remove-stale-comment-for-blk_mq_sched_mark_re.patch
queue-6.2/blk-iocost-fix-divide-by-0-error-in-calc_lcoefs.patch
queue-6.2/s390-dasd-fix-potential-memleak-in-dasd_eckd_init.patch
queue-6.2/blk-mq-correct-stale-comment-of-.get_budget.patch
queue-6.2/io_uring-add-a-conditional-reschedule-to-the-iopoll-cancelation-loop.patch
queue-6.2/block-bio-integrity-copy-flags-when-bio_integrity_pa.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux