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: turn implicit assumptions into a warning

io_req_complete_post() is now io-wq only and shouldn't be used outside
of it, i.e. it relies that io-wq holds a ref for the request as
explained in a comment below. Let's add a warning to enforce the
assumption and make sure nobody would try to do anything weird.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/1013b60c35d431d0698cafbc53c06f5917348c20.1712331455.git.asml.silence@gmail.com
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
de96e9ae f3913000

+11 -1
+11 -1
io_uring/io_uring.c
··· 930 930 struct io_ring_ctx *ctx = req->ctx; 931 931 932 932 /* 933 + * All execution paths but io-wq use the deferred completions by 934 + * passing IO_URING_F_COMPLETE_DEFER and thus should not end up here. 935 + */ 936 + if (WARN_ON_ONCE(!(issue_flags & IO_URING_F_IOWQ))) 937 + return; 938 + 939 + /* 933 940 * Handle special CQ sync cases via task_work. DEFER_TASKRUN requires 934 941 * the submitter task context, IOPOLL protects with uring_lock. 935 942 */ ··· 953 946 } 954 947 io_cq_unlock_post(ctx); 955 948 956 - /* called from io-wq submit work only, the ref won't drop to zero */ 949 + /* 950 + * We don't free the request here because we know it's called from 951 + * io-wq only, which holds a reference, so it cannot be the last put. 952 + */ 957 953 req_ref_put(req); 958 954 } 959 955