提交 b2607733 编写于 作者: X Xiaoguang Wang

io_uring: avoid unnecessary io_wq_work copy for fast poll feature

to #28736503

commit 405a5d2b2762f2a9813efdee93274d4e7bf607a1 upstream

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: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Acked-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Acked-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
上级 cfbe7e8b
...@@ -4254,7 +4254,8 @@ static void io_async_task_func(struct callback_head *cb) ...@@ -4254,7 +4254,8 @@ static void io_async_task_func(struct callback_head *cb)
spin_unlock_irq(&ctx->completion_lock); spin_unlock_irq(&ctx->completion_lock);
/* restore ->work in case we need to retry again */ /* restore ->work in case we need to retry again */
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); kfree(apoll);
if (!canceled) { if (!canceled) {
...@@ -4351,7 +4352,8 @@ static bool io_arm_poll_handler(struct io_kiocb *req) ...@@ -4351,7 +4352,8 @@ static bool io_arm_poll_handler(struct io_kiocb *req)
return false; return false;
req->flags |= REQ_F_POLLED; req->flags |= REQ_F_POLLED;
memcpy(&apoll->work, &req->work, sizeof(req->work)); if (req->flags & REQ_F_WORK_INITIALIZED)
memcpy(&apoll->work, &req->work, sizeof(req->work));
had_io = req->io != NULL; had_io = req->io != NULL;
get_task_struct(current); get_task_struct(current);
...@@ -4376,7 +4378,8 @@ static bool io_arm_poll_handler(struct io_kiocb *req) ...@@ -4376,7 +4378,8 @@ static bool io_arm_poll_handler(struct io_kiocb *req)
if (!had_io) if (!had_io)
io_poll_remove_double(req); io_poll_remove_double(req);
spin_unlock_irq(&ctx->completion_lock); spin_unlock_irq(&ctx->completion_lock);
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); kfree(apoll);
return false; return false;
} }
...@@ -4421,7 +4424,9 @@ static bool io_poll_remove_one(struct io_kiocb *req) ...@@ -4421,7 +4424,9 @@ static bool io_poll_remove_one(struct io_kiocb *req)
* io_req_work_drop_env below when dropping the * io_req_work_drop_env below when dropping the
* final reference. * 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); kfree(apoll);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册