io_uring: micro optimization of __io_sq_thread() condition
authorOlivier Langlois <olivier@trillion01.com>
Tue, 30 Jul 2024 20:56:06 +0000 (16:56 -0400)
committerJens Axboe <axboe@kernel.dk>
Sun, 25 Aug 2024 14:27:01 +0000 (08:27 -0600)
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 <olivier@trillion01.com>
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/052ca60b5c49e7439e4b8bd33bfab4a09d36d3d6.1722374371.git.olivier@trillion01.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/sqpoll.c

index 3b50dc9586d14fcb6a6b16e9fe29d029c86b15bc..e545bf240d3567e5c2a3478731ed6374c3144c9c 100644 (file)
@@ -176,7 +176,7 @@ static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries)
        if (cap_entries && to_submit > IORING_SQPOLL_CAP_ENTRIES_VALUE)
                to_submit = IORING_SQPOLL_CAP_ENTRIES_VALUE;
 
-       if (!wq_list_empty(&ctx->iopoll_list) || to_submit) {
+       if (to_submit || !wq_list_empty(&ctx->iopoll_list)) {
                const struct cred *creds = NULL;
 
                if (ctx->sq_creds != current_cred())