Skip to content

Commit

Permalink
io_uring: avoid unnecessary io_wq_work copy for fast poll feature
Browse files Browse the repository at this point in the history
to #28736503

commit 405a5d2 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: Xiaoguang Wang <[email protected]>
Acked-by: Joseph Qi <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
Signed-off-by: Xiaoguang Wang <[email protected]>
Acked-by: Joseph Qi <[email protected]>
  • Loading branch information
Xiaoguang Wang committed Jun 29, 2020
1 parent cfbe7e8 commit b260773
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -4254,7 +4254,8 @@ 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 */
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);

if (!canceled) {
Expand Down Expand Up @@ -4351,7 +4352,8 @@ static bool io_arm_poll_handler(struct io_kiocb *req)
return false;

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;

get_task_struct(current);
Expand All @@ -4376,7 +4378,8 @@ static bool io_arm_poll_handler(struct io_kiocb *req)
if (!had_io)
io_poll_remove_double(req);
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);
return false;
}
Expand Down Expand Up @@ -4421,7 +4424,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);
}
}
Expand Down

0 comments on commit b260773

Please sign in to comment.