Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/kbuf: remove legacy kbuf bulk allocation

Legacy provided buffers are slow and discouraged in favour of the ring
variant. Remove the bulk allocation to keep it simpler as we don't care
about performance.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/a064d70370e590efed8076e9501ae4cfc20fe0ca.1738724373.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
7919292a 92a3bac9

+5 -25
+5 -25
io_uring/kbuf.c
··· 501 501 return 0; 502 502 } 503 503 504 - #define IO_BUFFER_ALLOC_BATCH 64 505 - 506 504 static int io_refill_buffer_cache(struct io_ring_ctx *ctx) 507 505 { 508 - struct io_buffer *bufs[IO_BUFFER_ALLOC_BATCH]; 509 - int allocated; 506 + struct io_buffer *buf; 510 507 511 508 /* 512 509 * Completions that don't happen inline (eg not under uring_lock) will ··· 521 524 spin_unlock(&ctx->completion_lock); 522 525 } 523 526 524 - /* 525 - * No free buffers and no completion entries either. Allocate a new 526 - * batch of buffer entries and add those to our freelist. 527 - */ 528 - 529 - allocated = kmem_cache_alloc_bulk(io_buf_cachep, GFP_KERNEL_ACCOUNT, 530 - ARRAY_SIZE(bufs), (void **) bufs); 531 - if (unlikely(!allocated)) { 532 - /* 533 - * Bulk alloc is all-or-nothing. If we fail to get a batch, 534 - * retry single alloc to be on the safe side. 535 - */ 536 - bufs[0] = kmem_cache_alloc(io_buf_cachep, GFP_KERNEL); 537 - if (!bufs[0]) 538 - return -ENOMEM; 539 - allocated = 1; 540 - } 541 - 542 - while (allocated) 543 - list_add_tail(&bufs[--allocated]->list, &ctx->io_buffers_cache); 544 - 527 + buf = kmem_cache_alloc(io_buf_cachep, GFP_KERNEL); 528 + if (!buf) 529 + return -ENOMEM; 530 + list_add_tail(&buf->list, &ctx->io_buffers_cache); 545 531 return 0; 546 532 } 547 533