Linux io-uring development
 help / color / mirror / Atom feed
From: Gabriel Krisman Bertazi <krisman@suse.de>
To: axboe@kernel.dk, asml.silence@gmail.com
Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi <krisman@suse.de>
Subject: [PATCH 4/9] io_uring/poll: Allocate apoll with generic alloc_cache helper
Date: Mon, 18 Nov 2024 20:22:19 -0500	[thread overview]
Message-ID: <20241119012224.1698238-5-krisman@suse.de> (raw)
In-Reply-To: <20241119012224.1698238-1-krisman@suse.de>

This abstracts away the cache details to simplify the code.

Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
---
 io_uring/poll.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/io_uring/poll.c b/io_uring/poll.c
index bced9edd5233..837790ed6816 100644
--- a/io_uring/poll.c
+++ b/io_uring/poll.c
@@ -648,15 +648,12 @@ static struct async_poll *io_req_alloc_apoll(struct io_kiocb *req,
 	if (req->flags & REQ_F_POLLED) {
 		apoll = req->apoll;
 		kfree(apoll->double_poll);
-	} else if (!(issue_flags & IO_URING_F_UNLOCKED)) {
-		apoll = io_alloc_cache_get(&ctx->apoll_cache);
-		if (!apoll)
-			goto alloc_apoll;
-		apoll->poll.retries = APOLL_MAX_RETRY;
 	} else {
-alloc_apoll:
-		apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC);
-		if (unlikely(!apoll))
+		if (!(issue_flags & IO_URING_F_UNLOCKED))
+			apoll = io_alloc_cache_alloc(&ctx->apoll_cache, GFP_ATOMIC);
+		else
+			apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC);
+		if (!apoll)
 			return NULL;
 		apoll->poll.retries = APOLL_MAX_RETRY;
 	}
-- 
2.47.0


  parent reply	other threads:[~2024-11-19  1:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-19  1:22 [PATCH 0/9] Clean up alloc_cache allocations Gabriel Krisman Bertazi
2024-11-19  1:22 ` [PATCH 1/9] io_uring: Fold allocation into alloc_cache helper Gabriel Krisman Bertazi
2024-11-19  2:02   ` Jens Axboe
2024-11-19 15:30     ` Gabriel Krisman Bertazi
2024-11-19 16:18       ` Jens Axboe
2024-11-19  1:22 ` [PATCH 2/9] io_uring: Add generic helper to allocate async data Gabriel Krisman Bertazi
2024-11-19  1:22 ` [PATCH 3/9] io_uring/futex: Allocate ifd with generic alloc_cache helper Gabriel Krisman Bertazi
2024-11-19  1:22 ` Gabriel Krisman Bertazi [this message]
2024-11-19  1:22 ` [PATCH 5/9] io_uring/uring_cmd: Allocate async data through generic helper Gabriel Krisman Bertazi
2024-11-19  1:22 ` [PATCH 6/9] io_uring/net: Allocate msghdr async data through helper Gabriel Krisman Bertazi
2024-11-19  1:22 ` [PATCH 7/9] io_uring/rw: Allocate " Gabriel Krisman Bertazi
2024-11-19  1:22 ` [PATCH 8/9] io_uring: Move old async data allocation helper to header Gabriel Krisman Bertazi
2024-11-19  1:22 ` [PATCH 9/9] io_uring/msg_ring: Drop custom destructor Gabriel Krisman Bertazi
2024-11-19  2:05 ` [PATCH 0/9] Clean up alloc_cache allocations Jens Axboe
2024-11-19 15:31   ` Gabriel Krisman Bertazi

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=20241119012224.1698238-5-krisman@suse.de \
    --to=krisman@suse.de \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    /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