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/futex: move futexv async data handling to struct io_futexv_data

Rather than alloc an array of struct futex_vector for the futexv wait
handling, wrap it in a struct io_futexv_data struct, similar to what
the non-vectored futex wait handling does.

No functional changes in this patch.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

+15 -10
+15 -10
io_uring/futex.c
··· 28 28 struct io_kiocb *req; 29 29 }; 30 30 31 + struct io_futexv_data { 32 + struct futex_vector futexv[]; 33 + }; 34 + 31 35 #define IO_FUTEX_ALLOC_CACHE_MAX 32 32 36 33 37 bool io_futex_cache_init(struct io_ring_ctx *ctx) ··· 66 62 { 67 63 struct io_kiocb *req = tw_req.req; 68 64 struct io_futex *iof = io_kiocb_to_cmd(req, struct io_futex); 69 - struct futex_vector *futexv = req->async_data; 65 + struct io_futexv_data *ifd = req->async_data; 70 66 71 67 io_tw_lock(req->ctx, tw); 72 68 73 69 if (!iof->futexv_unqueued) { 74 70 int res; 75 71 76 - res = futex_unqueue_multiple(futexv, iof->futex_nr); 72 + res = futex_unqueue_multiple(ifd->futexv, iof->futex_nr); 77 73 if (res != -1) 78 74 io_req_set_res(req, res, 0); 79 75 } ··· 173 169 int io_futexv_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) 174 170 { 175 171 struct io_futex *iof = io_kiocb_to_cmd(req, struct io_futex); 176 - struct futex_vector *futexv; 172 + struct io_futexv_data *ifd; 177 173 int ret; 178 174 179 175 /* No flags or mask supported for waitv */ ··· 186 182 if (!iof->futex_nr || iof->futex_nr > FUTEX_WAITV_MAX) 187 183 return -EINVAL; 188 184 189 - futexv = kcalloc(iof->futex_nr, sizeof(*futexv), GFP_KERNEL); 190 - if (!futexv) 185 + ifd = kzalloc(struct_size_t(struct io_futexv_data, futexv, iof->futex_nr), 186 + GFP_KERNEL); 187 + if (!ifd) 191 188 return -ENOMEM; 192 189 193 - ret = futex_parse_waitv(futexv, iof->uaddr, iof->futex_nr, 190 + ret = futex_parse_waitv(ifd->futexv, iof->uaddr, iof->futex_nr, 194 191 io_futex_wakev_fn, req); 195 192 if (ret) { 196 - kfree(futexv); 193 + kfree(ifd); 197 194 return ret; 198 195 } 199 196 ··· 203 198 iof->futexv_owned = 0; 204 199 iof->futexv_unqueued = 0; 205 200 req->flags |= REQ_F_ASYNC_DATA; 206 - req->async_data = futexv; 201 + req->async_data = ifd; 207 202 return 0; 208 203 } 209 204 ··· 223 218 int io_futexv_wait(struct io_kiocb *req, unsigned int issue_flags) 224 219 { 225 220 struct io_futex *iof = io_kiocb_to_cmd(req, struct io_futex); 226 - struct futex_vector *futexv = req->async_data; 221 + struct io_futexv_data *ifd = req->async_data; 227 222 struct io_ring_ctx *ctx = req->ctx; 228 223 int ret, woken = -1; 229 224 230 225 io_ring_submit_lock(ctx, issue_flags); 231 226 232 - ret = futex_wait_multiple_setup(futexv, iof->futex_nr, &woken); 227 + ret = futex_wait_multiple_setup(ifd->futexv, iof->futex_nr, &woken); 233 228 234 229 /* 235 230 * Error case, ret is < 0. Mark the request as failed.