public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 2/7] io_uring: cache __io_free_req()'d requests
Date: Mon,  9 Aug 2021 20:18:08 +0100	[thread overview]
Message-ID: <9f4950fbe7771c8d41799366d0a3a08ac3040236.1628536684.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Don't kfree requests in __io_free_req() but put them back into the
internal request cache. That makes allocations more sustainable and will
be used for refcounting optimisations.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 889e11892227..9aa692625f42 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1826,11 +1826,16 @@ static void io_dismantle_req(struct io_kiocb *req)
 static void __io_free_req(struct io_kiocb *req)
 {
 	struct io_ring_ctx *ctx = req->ctx;
+	unsigned long flags;
 
 	io_dismantle_req(req);
 	io_put_task(req->task, 1);
 
-	kmem_cache_free(req_cachep, req);
+	spin_lock_irqsave(&ctx->completion_lock, flags);
+	list_add(&req->compl.list, &ctx->locked_free_list);
+	ctx->locked_free_nr++;
+	spin_unlock_irqrestore(&ctx->completion_lock, flags);
+
 	percpu_ref_put(&ctx->refs);
 }
 
-- 
2.32.0


  parent reply	other threads:[~2021-08-09 19:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09 19:18 [PATCH 0/7] the rest of for-next patches Pavel Begunkov
2021-08-09 19:18 ` [PATCH 1/7] io_uring: move io_fallback_req_func() Pavel Begunkov
2021-08-09 19:18 ` Pavel Begunkov [this message]
2021-08-09 19:18 ` [PATCH 3/7] io_uring: remove redundant args from cache_free Pavel Begunkov
2021-08-09 19:18 ` [PATCH 4/7] io_uring: use inflight_entry instead of compl.list Pavel Begunkov
2021-08-09 19:18 ` [PATCH 5/7] io_uring: inline struct io_comp_state Pavel Begunkov
2021-08-09 19:18 ` [PATCH 6/7] io_uring: remove extra argument for overflow flush Pavel Begunkov
2021-08-09 19:18 ` [PATCH 7/7] io_uring: inline io_poll_remove_waitqs Pavel Begunkov
2021-08-09 19:47 ` [PATCH 0/7] the rest of for-next patches 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=9f4950fbe7771c8d41799366d0a3a08ac3040236.1628536684.git.asml.silence@gmail.com \
    [email protected] \
    [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