Commit ce8e04f6 authored by Jens Axboe's avatar Jens Axboe

io_uring: consolidate the put_ref-and-return section of adding work

We've got a few cases of this, move them to one section and just use
gotos to get there. Reduces the text section on both arm64 and x86-64,
using gcc-12.2.
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 5b7c4cab
...@@ -1285,17 +1285,15 @@ static void io_req_local_work_add(struct io_kiocb *req) ...@@ -1285,17 +1285,15 @@ static void io_req_local_work_add(struct io_kiocb *req)
percpu_ref_get(&ctx->refs); percpu_ref_get(&ctx->refs);
if (!llist_add(&req->io_task_work.node, &ctx->work_llist)) { if (!llist_add(&req->io_task_work.node, &ctx->work_llist))
percpu_ref_put(&ctx->refs); goto put_ref;
return;
}
/* needed for the following wake up */ /* needed for the following wake up */
smp_mb__after_atomic(); smp_mb__after_atomic();
if (unlikely(atomic_read(&req->task->io_uring->in_idle))) { if (unlikely(atomic_read(&req->task->io_uring->in_idle))) {
io_move_task_work_from_local(ctx); io_move_task_work_from_local(ctx);
percpu_ref_put(&ctx->refs); goto put_ref;
return;
} }
if (ctx->flags & IORING_SETUP_TASKRUN_FLAG) if (ctx->flags & IORING_SETUP_TASKRUN_FLAG)
...@@ -1305,6 +1303,8 @@ static void io_req_local_work_add(struct io_kiocb *req) ...@@ -1305,6 +1303,8 @@ static void io_req_local_work_add(struct io_kiocb *req)
if (READ_ONCE(ctx->cq_waiting)) if (READ_ONCE(ctx->cq_waiting))
wake_up_state(ctx->submitter_task, TASK_INTERRUPTIBLE); wake_up_state(ctx->submitter_task, TASK_INTERRUPTIBLE);
put_ref:
percpu_ref_put(&ctx->refs); percpu_ref_put(&ctx->refs);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment