Skip to content

Commit 7255cd8

Browse files
Olivier Langloisaxboe
authored andcommitted
io_uring: micro optimization of __io_sq_thread() condition
reverse the order of the element evaluation in an if statement. for many users that are not using iopoll, the iopoll_list will always evaluate to false after having made a memory access whereas to_submit is very likely already loaded in a register. Signed-off-by: Olivier Langlois <[email protected]> Reviewed-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/052ca60b5c49e7439e4b8bd33bfab4a09d36d3d6.1722374371.git.olivier@trillion01.com Signed-off-by: Jens Axboe <[email protected]>
1 parent a8edbb4 commit 7255cd8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

io_uring/sqpoll.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries)
176176
if (cap_entries && to_submit > IORING_SQPOLL_CAP_ENTRIES_VALUE)
177177
to_submit = IORING_SQPOLL_CAP_ENTRIES_VALUE;
178178

179-
if (!wq_list_empty(&ctx->iopoll_list) || to_submit) {
179+
if (to_submit || !wq_list_empty(&ctx->iopoll_list)) {
180180
const struct cred *creds = NULL;
181181

182182
if (ctx->sq_creds != current_cred())

0 commit comments

Comments
 (0)