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: make io_alloc_ocqe() take a struct io_cqe pointer

The number of arguments to io_alloc_ocqe() is a bit unwieldy. Make it
take a struct io_cqe pointer rather than three separate CQE args. One
path already has that readily available, add an io_init_cqe() helper for
the remaining two.

Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

+16 -10
+16 -10
io_uring/io_uring.c
··· 724 724 } 725 725 726 726 static struct io_overflow_cqe *io_alloc_ocqe(struct io_ring_ctx *ctx, 727 - u64 user_data, s32 res, u32 cflags, 728 - u64 extra1, u64 extra2, gfp_t gfp) 727 + struct io_cqe *cqe, u64 extra1, 728 + u64 extra2, gfp_t gfp) 729 729 { 730 730 struct io_overflow_cqe *ocqe; 731 731 size_t ocq_size = sizeof(struct io_overflow_cqe); ··· 735 735 ocq_size += sizeof(struct io_uring_cqe); 736 736 737 737 ocqe = kmalloc(ocq_size, gfp | __GFP_ACCOUNT); 738 - trace_io_uring_cqe_overflow(ctx, user_data, res, cflags, ocqe); 738 + trace_io_uring_cqe_overflow(ctx, cqe->user_data, cqe->res, cqe->flags, ocqe); 739 739 if (ocqe) { 740 - ocqe->cqe.user_data = user_data; 741 - ocqe->cqe.res = res; 742 - ocqe->cqe.flags = cflags; 740 + ocqe->cqe.user_data = cqe->user_data; 741 + ocqe->cqe.res = cqe->res; 742 + ocqe->cqe.flags = cqe->flags; 743 743 if (is_cqe32) { 744 744 ocqe->cqe.big_cqe[0] = extra1; 745 745 ocqe->cqe.big_cqe[1] = extra2; ··· 806 806 return false; 807 807 } 808 808 809 + static inline struct io_cqe io_init_cqe(u64 user_data, s32 res, u32 cflags) 810 + { 811 + return (struct io_cqe) { .user_data = user_data, .res = res, .flags = cflags }; 812 + } 813 + 809 814 bool io_post_aux_cqe(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags) 810 815 { 811 816 bool filled; ··· 819 814 filled = io_fill_cqe_aux(ctx, user_data, res, cflags); 820 815 if (unlikely(!filled)) { 821 816 struct io_overflow_cqe *ocqe; 817 + struct io_cqe cqe = io_init_cqe(user_data, res, cflags); 822 818 823 - ocqe = io_alloc_ocqe(ctx, user_data, res, cflags, 0, 0, GFP_ATOMIC); 819 + ocqe = io_alloc_ocqe(ctx, &cqe, 0, 0, GFP_ATOMIC); 824 820 filled = io_cqring_add_overflow(ctx, ocqe); 825 821 } 826 822 io_cq_unlock_post(ctx); ··· 839 833 840 834 if (!io_fill_cqe_aux(ctx, user_data, res, cflags)) { 841 835 struct io_overflow_cqe *ocqe; 836 + struct io_cqe cqe = io_init_cqe(user_data, res, cflags); 842 837 843 - ocqe = io_alloc_ocqe(ctx, user_data, res, cflags, 0, 0, GFP_KERNEL); 838 + ocqe = io_alloc_ocqe(ctx, &cqe, 0, 0, GFP_KERNEL); 844 839 spin_lock(&ctx->completion_lock); 845 840 io_cqring_add_overflow(ctx, ocqe); 846 841 spin_unlock(&ctx->completion_lock); ··· 1451 1444 gfp_t gfp = ctx->lockless_cq ? GFP_KERNEL : GFP_ATOMIC; 1452 1445 struct io_overflow_cqe *ocqe; 1453 1446 1454 - ocqe = io_alloc_ocqe(ctx, req->cqe.user_data, req->cqe.res, 1455 - req->cqe.flags, req->big_cqe.extra1, 1447 + ocqe = io_alloc_ocqe(ctx, &req->cqe, req->big_cqe.extra1, 1456 1448 req->big_cqe.extra2, gfp); 1457 1449 if (ctx->lockless_cq) { 1458 1450 spin_lock(&ctx->completion_lock);