io_uring/futex: Allocate ifd with generic alloc_cache helper
authorGabriel Krisman Bertazi <krisman@suse.de>
Mon, 16 Dec 2024 20:46:09 +0000 (15:46 -0500)
committerJens Axboe <axboe@kernel.dk>
Fri, 27 Dec 2024 17:07:17 +0000 (10:07 -0700)
Instead of open-coding the allocation, use the generic alloc_cache
helper.

Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
Link: https://lore.kernel.org/r/20241216204615.759089-4-krisman@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/futex.c

index e29662f039e1a13ad22e1e581ccc54aa7a390622..30139cc150f2280569cc6bb8830b4f6ac5a06620 100644 (file)
@@ -251,17 +251,6 @@ static void io_futex_wake_fn(struct wake_q_head *wake_q, struct futex_q *q)
        io_req_task_work_add(req);
 }
 
-static struct io_futex_data *io_alloc_ifd(struct io_ring_ctx *ctx)
-{
-       struct io_futex_data *ifd;
-
-       ifd = io_alloc_cache_get(&ctx->futex_cache);
-       if (ifd)
-               return ifd;
-
-       return kmalloc(sizeof(struct io_futex_data), GFP_NOWAIT);
-}
-
 int io_futexv_wait(struct io_kiocb *req, unsigned int issue_flags)
 {
        struct io_futex *iof = io_kiocb_to_cmd(req, struct io_futex);
@@ -331,7 +320,7 @@ int io_futex_wait(struct io_kiocb *req, unsigned int issue_flags)
        }
 
        io_ring_submit_lock(ctx, issue_flags);
-       ifd = io_alloc_ifd(ctx);
+       ifd = io_cache_alloc(&ctx->futex_cache, GFP_NOWAIT, NULL);
        if (!ifd) {
                ret = -ENOMEM;
                goto done_unlock;