Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring: Move old async data allocation helper to header

There are two remaining uses of the old async data allocator that do not
rely on the alloc cache. I don't want to make them use the new
allocator helper because that would require a if(cache) check, which
will result in dead code for the cached case (for callers passing a
cache, gcc can't prove the cache isn't NULL, and will therefore preserve
the check. Since this is an inline function and just a few lines long,
keep a second helper to deal with cases where we don't have an async
data cache.

No functional change intended here. This is just moving the helper
around and making it inline.

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

authored by

Gabriel Krisman Bertazi and committed by
Jens Axboe
ef623a64 d7f11616

+16 -18
-13
io_uring/io_uring.c
··· 1643 1643 return res; 1644 1644 } 1645 1645 1646 - bool io_alloc_async_data(struct io_kiocb *req) 1647 - { 1648 - const struct io_issue_def *def = &io_issue_defs[req->opcode]; 1649 - 1650 - WARN_ON_ONCE(!def->async_size); 1651 - req->async_data = kmalloc(def->async_size, GFP_KERNEL); 1652 - if (req->async_data) { 1653 - req->flags |= REQ_F_ASYNC_DATA; 1654 - return false; 1655 - } 1656 - return true; 1657 - } 1658 - 1659 1646 static u32 io_get_sequence(struct io_kiocb *req) 1660 1647 { 1661 1648 u32 seq = req->ctx->cached_sq_head;
+12
io_uring/io_uring.h
··· 12 12 #include "io-wq.h" 13 13 #include "slist.h" 14 14 #include "filetable.h" 15 + #include "opdef.h" 15 16 16 17 #ifndef CREATE_TRACE_POINTS 17 18 #include <trace/events/io_uring.h> ··· 229 228 void (*init_once)(void *obj)) 230 229 { 231 230 req->async_data = io_cache_alloc(cache, GFP_KERNEL, init_once); 231 + if (req->async_data) 232 + req->flags |= REQ_F_ASYNC_DATA; 233 + return req->async_data; 234 + } 235 + 236 + static inline void *io_uring_alloc_async_data_nocache(struct io_kiocb *req) 237 + { 238 + const struct io_issue_def *def = &io_issue_defs[req->opcode]; 239 + 240 + WARN_ON_ONCE(!def->async_size); 241 + req->async_data = kmalloc(def->async_size, GFP_KERNEL); 232 242 if (req->async_data) 233 243 req->flags |= REQ_F_ASYNC_DATA; 234 244 return req->async_data;
+2 -3
io_uring/timeout.c
··· 525 525 526 526 if (WARN_ON_ONCE(req_has_async_data(req))) 527 527 return -EFAULT; 528 - if (io_alloc_async_data(req)) 528 + data = io_uring_alloc_async_data_nocache(req); 529 + if (!data) 529 530 return -ENOMEM; 530 - 531 - data = req->async_data; 532 531 data->req = req; 533 532 data->flags = flags; 534 533
+2 -2
io_uring/waitid.c
··· 303 303 struct io_waitid_async *iwa; 304 304 int ret; 305 305 306 - if (io_alloc_async_data(req)) 306 + iwa = io_uring_alloc_async_data_nocache(req); 307 + if (!iwa) 307 308 return -ENOMEM; 308 309 309 - iwa = req->async_data; 310 310 iwa->req = req; 311 311 312 312 ret = kernel_waitid_prepare(&iwa->wo, iw->which, iw->upid, &iw->info,