diff mbox series

[1/2] io_uring: micro optimization of __io_sq_thread() condition

Message ID 052ca60b5c49e7439e4b8bd33bfab4a09d36d3d6.1722374371.git.olivier@trillion01.com (mailing list archive)
State New
Headers show
Series io_uring: minor sqpoll code refactoring | expand

Commit Message

Olivier Langlois July 30, 2024, 8:56 p.m. UTC
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>
---
 io_uring/sqpoll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Pavel Begunkov Aug. 2, 2024, 11:17 a.m. UTC | #1
On 7/30/24 21:56, Olivier Langlois wrote:
> 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.

doubt it'd make any difference, but it might be useful if sqpoll
submits requests often enough.

Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>


> Signed-off-by: Olivier Langlois <olivier@trillion01.com>
> ---
>   io_uring/sqpoll.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c
> index b3722e5275e7..cc4a25136030 100644
> --- a/io_uring/sqpoll.c
> +++ b/io_uring/sqpoll.c
> @@ -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())
diff mbox series

Patch

diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c
index b3722e5275e7..cc4a25136030 100644
--- a/io_uring/sqpoll.c
+++ b/io_uring/sqpoll.c
@@ -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())