IO-Uring Archive on
 help / color / Atom feed
* [PATCH] io_uring: enable optimized link handling for IORING_OP_POLL_ADD
@ 2019-11-05 22:23 Jens Axboe
  0 siblings, 0 replies; only message in thread
From: Jens Axboe @ 2019-11-05 22:23 UTC (permalink / raw)
  To: unlisted-recipients:; (no To-header on input); +Cc: linux-block, io-uring

As introduced by commit:

ba816ad61fdf ("io_uring: run dependent links inline if possible")

enable inline dependent link running for poll commands.
io_poll_complete_work() is the most important change, as it allows a
linked sequence of { POLL, READ } (for example) to proceed inline
instead of needing to get punted to another async context. The
submission side only potentially matters for sqthread, but may as well
include that bit.

Signed-off-by: Jens Axboe <>


diff --git a/fs/io_uring.c b/fs/io_uring.c
index d4ff3e49a78c..d074f3f04a63 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1862,6 +1862,7 @@ static void io_poll_complete_work(struct io_wq_work **workptr)
 	struct io_poll_iocb *poll = &req->poll;
 	struct poll_table_struct pt = { ._key = poll->events };
 	struct io_ring_ctx *ctx = req->ctx;
+	struct io_kiocb *nxt = NULL;
 	__poll_t mask = 0;
 	if (work->flags & IO_WQ_WORK_CANCEL)
@@ -1888,7 +1889,10 @@ static void io_poll_complete_work(struct io_wq_work **workptr)
-	io_put_req(req, NULL);
+	io_put_req(req, &nxt);
+	if (nxt)
+		*workptr = &nxt->work;
 static int io_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,
@@ -1942,7 +1946,8 @@ static void io_poll_queue_proc(struct file *file, struct wait_queue_head *head,
 	add_wait_queue(head, &pt->req->poll.wait);
-static int io_poll_add(struct io_kiocb *req, const struct io_uring_sqe *sqe)
+static int io_poll_add(struct io_kiocb *req, const struct io_uring_sqe *sqe,
+		       struct io_kiocb **nxt)
 	struct io_poll_iocb *poll = &req->poll;
 	struct io_ring_ctx *ctx = req->ctx;
@@ -2005,7 +2010,7 @@ static int io_poll_add(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 	if (mask) {
-		io_put_req(req, NULL);
+		io_put_req(req, nxt);
 	return ipt.error;
@@ -2303,7 +2308,7 @@ static int __io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req,
 		ret = io_fsync(req, s->sqe, nxt, force_nonblock);
-		ret = io_poll_add(req, s->sqe);
+		ret = io_poll_add(req, s->sqe, nxt);
 		ret = io_poll_remove(req, s->sqe);

Jens Axboe

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-05 22:23 [PATCH] io_uring: enable optimized link handling for IORING_OP_POLL_ADD Jens Axboe

IO-Uring Archive on

Archives are clonable:
	git clone --mirror io-uring/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 io-uring io-uring/ \
	public-inbox-index io-uring

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone