Skip to content

Commit 8bab4c0

Browse files
committed
io_uring: allow conditional reschedule for intensive iterators
If we have a lot of threads and rings, the tctx list can get quite big. This is especially true if we keep creating new threads and rings. Likewise for the provided buffers list. Be nice and insert a conditional reschedule point while iterating the nodes for deletion. Link: https://lore.kernel.org/io-uring/[email protected]/ Reported-by: [email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 5b7aa38 commit 8bab4c0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/io_uring.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9173,8 +9173,10 @@ static void io_destroy_buffers(struct io_ring_ctx *ctx)
91739173
struct io_buffer *buf;
91749174
unsigned long index;
91759175

9176-
xa_for_each(&ctx->io_buffers, index, buf)
9176+
xa_for_each(&ctx->io_buffers, index, buf) {
91779177
__io_remove_buffers(ctx, buf, index, -1U);
9178+
cond_resched();
9179+
}
91789180
}
91799181

91809182
static void io_req_cache_free(struct list_head *list)
@@ -9672,8 +9674,10 @@ static void io_uring_clean_tctx(struct io_uring_task *tctx)
96729674
struct io_tctx_node *node;
96739675
unsigned long index;
96749676

9675-
xa_for_each(&tctx->xa, index, node)
9677+
xa_for_each(&tctx->xa, index, node) {
96769678
io_uring_del_tctx_node(index);
9679+
cond_resched();
9680+
}
96779681
if (wq) {
96789682
/*
96799683
* Must be after io_uring_del_task_file() (removes nodes under

0 commit comments

Comments
 (0)