diff options
author | Olivier Langlois <olivier@trillion01.com> | 2024-10-13 14:29:12 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-11-06 13:55:38 -0700 |
commit | 71afd926f292bb8f3ca86e6c3c40123037f109c6 (patch) | |
tree | a48c5105f99cc4f79b5c7ef2bb0f24e3fe306c2f /io_uring | |
parent | db1e1adf6f993b1c2cef605d86eff709a8db5052 (diff) |
io_uring/napi: clean up __io_napi_do_busy_loop
__io_napi_do_busy_loop now requires to have loop_end in its parameters.
This makes the code cleaner and also has the benefit of removing a
branch since the only caller not passing NULL for loop_end_arg is also
setting the value conditionally.
Signed-off-by: Olivier Langlois <olivier@trillion01.com>
Link: https://lore.kernel.org/r/d5b9bb91b1a08fff50525e1c18d7b4709b9ca100.1728828877.git.olivier@trillion01.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring')
-rw-r--r-- | io_uring/napi.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/io_uring/napi.c b/io_uring/napi.c index 6d5fdd397f2f..1de1543d8034 100644 --- a/io_uring/napi.c +++ b/io_uring/napi.c @@ -137,15 +137,12 @@ static bool io_napi_busy_loop_should_end(void *data, } static bool __io_napi_do_busy_loop(struct io_ring_ctx *ctx, + bool (*loop_end)(void *, unsigned long), void *loop_end_arg) { struct io_napi_entry *e; - bool (*loop_end)(void *, unsigned long) = NULL; bool is_stale = false; - if (loop_end_arg) - loop_end = io_napi_busy_loop_should_end; - list_for_each_entry_rcu(e, &ctx->napi_list, list) { napi_busy_loop_rcu(e->napi_id, loop_end, loop_end_arg, ctx->napi_prefer_busy_poll, BUSY_POLL_BUDGET); @@ -161,18 +158,22 @@ static void io_napi_blocking_busy_loop(struct io_ring_ctx *ctx, struct io_wait_queue *iowq) { unsigned long start_time = busy_loop_current_time(); + bool (*loop_end)(void *, unsigned long) = NULL; void *loop_end_arg = NULL; bool is_stale = false; /* Singular lists use a different napi loop end check function and are * only executed once. */ - if (list_is_singular(&ctx->napi_list)) + if (list_is_singular(&ctx->napi_list)) { + loop_end = io_napi_busy_loop_should_end; loop_end_arg = iowq; + } scoped_guard(rcu) { do { - is_stale = __io_napi_do_busy_loop(ctx, loop_end_arg); + is_stale = __io_napi_do_busy_loop(ctx, loop_end, + loop_end_arg); } while (!io_napi_busy_loop_should_end(iowq, start_time) && !loop_end_arg); } @@ -308,7 +309,7 @@ int io_napi_sqpoll_busy_poll(struct io_ring_ctx *ctx) return 0; scoped_guard(rcu) { - is_stale = __io_napi_do_busy_loop(ctx, NULL); + is_stale = __io_napi_do_busy_loop(ctx, NULL, NULL); } io_napi_remove_stale(ctx, is_stale); |