public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH 1/8] io_uring/kbuf: remove legacy kbuf bulk allocation
Date: Wed,  5 Feb 2025 11:36:42 +0000	[thread overview]
Message-ID: <a064d70370e590efed8076e9501ae4cfc20fe0ca.1738724373.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

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 <[email protected]>
---
 io_uring/kbuf.c | 30 +++++-------------------------
 1 file changed, 5 insertions(+), 25 deletions(-)

diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c
index 04bf493eecae0..0bed40f6fe3a5 100644
--- a/io_uring/kbuf.c
+++ b/io_uring/kbuf.c
@@ -494,12 +494,9 @@ int io_provide_buffers_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
 	return 0;
 }
 
-#define IO_BUFFER_ALLOC_BATCH 64
-
 static int io_refill_buffer_cache(struct io_ring_ctx *ctx)
 {
-	struct io_buffer *bufs[IO_BUFFER_ALLOC_BATCH];
-	int allocated;
+	struct io_buffer *buf;
 
 	/*
 	 * Completions that don't happen inline (eg not under uring_lock) will
@@ -517,27 +514,10 @@ static int io_refill_buffer_cache(struct io_ring_ctx *ctx)
 		spin_unlock(&ctx->completion_lock);
 	}
 
-	/*
-	 * No free buffers and no completion entries either. Allocate a new
-	 * batch of buffer entries and add those to our freelist.
-	 */
-
-	allocated = kmem_cache_alloc_bulk(io_buf_cachep, GFP_KERNEL_ACCOUNT,
-					  ARRAY_SIZE(bufs), (void **) bufs);
-	if (unlikely(!allocated)) {
-		/*
-		 * Bulk alloc is all-or-nothing. If we fail to get a batch,
-		 * retry single alloc to be on the safe side.
-		 */
-		bufs[0] = kmem_cache_alloc(io_buf_cachep, GFP_KERNEL);
-		if (!bufs[0])
-			return -ENOMEM;
-		allocated = 1;
-	}
-
-	while (allocated)
-		list_add_tail(&bufs[--allocated]->list, &ctx->io_buffers_cache);
-
+	buf = kmem_cache_alloc(io_buf_cachep, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+	list_add_tail(&buf->list, &ctx->io_buffers_cache);
 	return 0;
 }
 
-- 
2.47.1


  reply	other threads:[~2025-02-05 11:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 11:36 [PATCH 0/8] legacy provided buffer deprecation / deoptimisation Pavel Begunkov
2025-02-05 11:36 ` Pavel Begunkov [this message]
2025-02-05 11:36 ` [PATCH 2/8] io_uring/kbuf: remove legacy kbuf kmem cache Pavel Begunkov
2025-02-05 11:36 ` [PATCH 3/8] io_uring/kbuf: move locking into io_kbuf_drop() Pavel Begunkov
2025-02-05 11:36 ` [PATCH 4/8] io_uring/kbuf: simplify __io_put_kbuf Pavel Begunkov
2025-02-05 11:36 ` [PATCH 5/8] io_uring/kbuf: remove legacy kbuf caching Pavel Begunkov
2025-02-05 11:36 ` [PATCH 6/8] io_uring/kbuf: open code __io_put_kbuf() Pavel Begunkov
2025-02-05 11:36 ` [PATCH 7/8] io_uring/kbuf: introduce io_kbuf_drop_legacy() Pavel Begunkov
2025-02-05 11:36 ` [PATCH 8/8] io_uring/kbuf: uninline __io_put_kbufs Pavel Begunkov
2025-02-05 16:17 ` [PATCH 0/8] legacy provided buffer deprecation / deoptimisation Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a064d70370e590efed8076e9501ae4cfc20fe0ca.1738724373.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox