aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGabriel Krisman Bertazi <krisman@suse.de>2024-12-16 15:46:08 -0500
committerJens Axboe <axboe@kernel.dk>2024-12-27 10:07:05 -0700
commit49f7a3098cc2406c9cf60d595f4a148d6780bce6 (patch)
treedeceecfed2ff3eafdf6183232c4b7ae483909a12
parentio_uring: Fold allocation into alloc_cache helper (diff)
downloadwireguard-linux-49f7a3098cc2406c9cf60d595f4a148d6780bce6.tar.xz
wireguard-linux-49f7a3098cc2406c9cf60d595f4a148d6780bce6.zip
io_uring: Add generic helper to allocate async data
This helper replaces io_alloc_async_data by using the folded allocation. Do it in a header to allow the compiler to decide whether to inline. Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de> Link: https://lore.kernel.org/r/20241216204615.759089-3-krisman@suse.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--io_uring/io_uring.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h
index 12abee607e4a..e43e9194dd0a 100644
--- a/io_uring/io_uring.h
+++ b/io_uring/io_uring.h
@@ -8,6 +8,7 @@
#include <linux/poll.h>
#include <linux/io_uring_types.h>
#include <uapi/linux/eventpoll.h>
+#include "alloc_cache.h"
#include "io-wq.h"
#include "slist.h"
#include "filetable.h"
@@ -222,6 +223,16 @@ static inline void io_req_set_res(struct io_kiocb *req, s32 res, u32 cflags)
req->cqe.flags = cflags;
}
+static inline void *io_uring_alloc_async_data(struct io_alloc_cache *cache,
+ struct io_kiocb *req,
+ void (*init_once)(void *obj))
+{
+ req->async_data = io_cache_alloc(cache, GFP_KERNEL, init_once);
+ if (req->async_data)
+ req->flags |= REQ_F_ASYNC_DATA;
+ return req->async_data;
+}
+
static inline bool req_has_async_data(struct io_kiocb *req)
{
return req->flags & REQ_F_ASYNC_DATA;