Commit 405a5d2b authored by Xiaoguang Wang's avatar Xiaoguang Wang Committed by Jens Axboe
Browse files

io_uring: avoid unnecessary io_wq_work copy for fast poll feature



Basically IORING_OP_POLL_ADD command and async armed poll handlers
for regular commands don't touch io_wq_work, so only REQ_F_WORK_INITIALIZED
is set, can we do io_wq_work copy and restore.

Signed-off-by: default avatarXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 7cdaf587
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -4262,6 +4262,7 @@ static void io_async_task_func(struct callback_head *cb)
	spin_unlock_irq(&ctx->completion_lock);

	/* restore ->work in case we need to retry again */
	if (req->flags & REQ_F_WORK_INITIALIZED)
		memcpy(&req->work, &apoll->work, sizeof(req->work));
	kfree(apoll);

@@ -4359,6 +4360,7 @@ static bool io_arm_poll_handler(struct io_kiocb *req)
		return false;

	req->flags |= REQ_F_POLLED;
	if (req->flags & REQ_F_WORK_INITIALIZED)
		memcpy(&apoll->work, &req->work, sizeof(req->work));
	had_io = req->io != NULL;

@@ -4384,6 +4386,7 @@ static bool io_arm_poll_handler(struct io_kiocb *req)
		if (!had_io)
			io_poll_remove_double(req);
		spin_unlock_irq(&ctx->completion_lock);
		if (req->flags & REQ_F_WORK_INITIALIZED)
			memcpy(&req->work, &apoll->work, sizeof(req->work));
		kfree(apoll);
		return false;
@@ -4429,7 +4432,9 @@ static bool io_poll_remove_one(struct io_kiocb *req)
			 * io_req_work_drop_env below when dropping the
			 * final reference.
			 */
			memcpy(&req->work, &apoll->work, sizeof(req->work));
			if (req->flags & REQ_F_WORK_INITIALIZED)
				memcpy(&req->work, &apoll->work,
				       sizeof(req->work));
			kfree(apoll);
		}
	}