Skip to content

Commit 05eb5fe

Browse files
committed
io_uring: refill request cache in memory order
The allocator will generally return memory in order, but __io_alloc_req_refill() then adds them to a stack and we'll extract them in the opposite order. This obviously isn't a huge deal, but: 1) it makes debugging easier when they are in order 2) keeping them in-order is the right thing to do 3) reduces the code for adding them to the stack Just add them in reverse to the stack. Signed-off-by: Jens Axboe <[email protected]>
1 parent da22bdf commit 05eb5fe

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

io_uring/io_uring.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ __cold bool __io_alloc_req_refill(struct io_ring_ctx *ctx)
10391039
{
10401040
gfp_t gfp = GFP_KERNEL | __GFP_NOWARN;
10411041
void *reqs[IO_REQ_ALLOC_BATCH];
1042-
int ret, i;
1042+
int ret;
10431043

10441044
/*
10451045
* If we have more than a batch's worth of requests in our IRQ side
@@ -1066,8 +1066,8 @@ __cold bool __io_alloc_req_refill(struct io_ring_ctx *ctx)
10661066
}
10671067

10681068
percpu_ref_get_many(&ctx->refs, ret);
1069-
for (i = 0; i < ret; i++) {
1070-
struct io_kiocb *req = reqs[i];
1069+
while (ret--) {
1070+
struct io_kiocb *req = reqs[ret];
10711071

10721072
io_preinit_req(req, ctx);
10731073
io_req_add_to_cache(req, ctx);

0 commit comments

Comments
 (0)