Skip to content

Commit 5916943

Browse files
isilenceaxboe
authored andcommitted
io_uring: conditional ->async_data allocation
There are opcodes that need ->async_data only in some cases and allocation it unconditionally may hurt performance. Add an option to opdef to make move the allocation part from the core io_uring to opcode specific code. Note, we can't just set opdef->async_size to zero because there are other helpers that rely on it, e.g. io_alloc_async_data(). Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/9dc62be9e88dd0ed63c48365340e8922d2498293.1661342812.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 53bdc88 commit 5916943

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

io_uring/io_uring.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,9 +1450,10 @@ int io_req_prep_async(struct io_kiocb *req)
14501450
return 0;
14511451
if (WARN_ON_ONCE(req_has_async_data(req)))
14521452
return -EFAULT;
1453-
if (io_alloc_async_data(req))
1454-
return -EAGAIN;
1455-
1453+
if (!io_op_defs[req->opcode].manual_alloc) {
1454+
if (io_alloc_async_data(req))
1455+
return -EAGAIN;
1456+
}
14561457
return def->prep_async(req);
14571458
}
14581459

io_uring/opdef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ struct io_op_def {
2525
unsigned ioprio : 1;
2626
/* supports iopoll */
2727
unsigned iopoll : 1;
28+
/* opcode specific path will handle ->async_data allocation if needed */
29+
unsigned manual_alloc : 1;
2830
/* size of async data needed, if any */
2931
unsigned short async_size;
3032

0 commit comments

Comments
 (0)