Skip to content

Commit 71afd92

Browse files
Olivier Langloisaxboe
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/d5b9bb91b1a08fff50525e1c18d7b4709b9ca100.1728828877.git.olivier@trillion01.com Signed-off-by: Jens Axboe <[email protected]>
1 parent db1e1ad commit 71afd92

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

io_uring/napi.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,12 @@ static bool io_napi_busy_loop_should_end(void *data,
137137
}
138138

139139
static bool __io_napi_do_busy_loop(struct io_ring_ctx *ctx,
140+
bool (*loop_end)(void *, unsigned long),
140141
void *loop_end_arg)
141142
{
142143
struct io_napi_entry *e;
143-
bool (*loop_end)(void *, unsigned long) = NULL;
144144
bool is_stale = false;
145145

146-
if (loop_end_arg)
147-
loop_end = io_napi_busy_loop_should_end;
148-
149146
list_for_each_entry_rcu(e, &ctx->napi_list, list) {
150147
napi_busy_loop_rcu(e->napi_id, loop_end, loop_end_arg,
151148
ctx->napi_prefer_busy_poll, BUSY_POLL_BUDGET);
@@ -161,18 +158,22 @@ static void io_napi_blocking_busy_loop(struct io_ring_ctx *ctx,
161158
struct io_wait_queue *iowq)
162159
{
163160
unsigned long start_time = busy_loop_current_time();
161+
bool (*loop_end)(void *, unsigned long) = NULL;
164162
void *loop_end_arg = NULL;
165163
bool is_stale = false;
166164

167165
/* Singular lists use a different napi loop end check function and are
168166
* only executed once.
169167
*/
170-
if (list_is_singular(&ctx->napi_list))
168+
if (list_is_singular(&ctx->napi_list)) {
169+
loop_end = io_napi_busy_loop_should_end;
171170
loop_end_arg = iowq;
171+
}
172172

173173
scoped_guard(rcu) {
174174
do {
175-
is_stale = __io_napi_do_busy_loop(ctx, loop_end_arg);
175+
is_stale = __io_napi_do_busy_loop(ctx, loop_end,
176+
loop_end_arg);
176177
} while (!io_napi_busy_loop_should_end(iowq, start_time) &&
177178
!loop_end_arg);
178179
}
@@ -308,7 +309,7 @@ int io_napi_sqpoll_busy_poll(struct io_ring_ctx *ctx)
308309
return 0;
309310

310311
scoped_guard(rcu) {
311-
is_stale = __io_napi_do_busy_loop(ctx, NULL);
312+
is_stale = __io_napi_do_busy_loop(ctx, NULL, NULL);
312313
}
313314

314315
io_napi_remove_stale(ctx, is_stale);

0 commit comments

Comments
 (0)