Skip to content

Commit ce8e04f

Browse files
committed
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: Jens Axboe <[email protected]>
1 parent 5b7c4ca commit ce8e04f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

io_uring/io_uring.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,17 +1285,15 @@ static void io_req_local_work_add(struct io_kiocb *req)
12851285

12861286
percpu_ref_get(&ctx->refs);
12871287

1288-
if (!llist_add(&req->io_task_work.node, &ctx->work_llist)) {
1289-
percpu_ref_put(&ctx->refs);
1290-
return;
1291-
}
1288+
if (!llist_add(&req->io_task_work.node, &ctx->work_llist))
1289+
goto put_ref;
1290+
12921291
/* needed for the following wake up */
12931292
smp_mb__after_atomic();
12941293

12951294
if (unlikely(atomic_read(&req->task->io_uring->in_idle))) {
12961295
io_move_task_work_from_local(ctx);
1297-
percpu_ref_put(&ctx->refs);
1298-
return;
1296+
goto put_ref;
12991297
}
13001298

13011299
if (ctx->flags & IORING_SETUP_TASKRUN_FLAG)
@@ -1305,6 +1303,8 @@ static void io_req_local_work_add(struct io_kiocb *req)
13051303

13061304
if (READ_ONCE(ctx->cq_waiting))
13071305
wake_up_state(ctx->submitter_task, TASK_INTERRUPTIBLE);
1306+
1307+
put_ref:
13081308
percpu_ref_put(&ctx->refs);
13091309
}
13101310

0 commit comments

Comments
 (0)