summaryrefslogtreecommitdiff
path: root/io_uring/io_uring.h
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2022-09-08 18:56:52 +0300
committerJens Axboe <axboe@kernel.dk>2022-09-21 22:14:46 +0300
commit76de6749d1bc1817367fedda94cd7c5d325df6c4 (patch)
treef51fef426073ca174c3e6baab5bb0e400eb6a0ae /io_uring/io_uring.h
parentac9e5784bbe72f4f603d1af84760ec09bc0b5ccd (diff)
downloadlinux-76de6749d1bc1817367fedda94cd7c5d325df6c4.tar.xz
io_uring: further limit non-owner defer-tw cq waiting
In case of DEFER_TASK_WORK we try to restrict waiters to only one task, which is also the only submitter; however, we don't do it reliably, which might be very confusing and backfire in the future. E.g. we currently allow multiple tasks in io_iopoll_check(). Fixes: c0e0d6ba25f1 ("io_uring: add IORING_SETUP_DEFER_TASKRUN") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Reviewed-by: Dylan Yudaken <dylany@fb.com> Link: https://lore.kernel.org/r/94c83c0a7fe468260ee2ec31bdb0095d6e874ba2.1662652536.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/io_uring.h')
-rw-r--r--io_uring/io_uring.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h
index 9d89425292b7..4eea0836170e 100644
--- a/io_uring/io_uring.h
+++ b/io_uring/io_uring.h
@@ -329,4 +329,15 @@ static inline struct io_kiocb *io_alloc_req(struct io_ring_ctx *ctx)
return container_of(node, struct io_kiocb, comp_list);
}
+static inline bool io_allowed_run_tw(struct io_ring_ctx *ctx)
+{
+ if (!(ctx->flags & IORING_SETUP_DEFER_TASKRUN))
+ return true;
+ if (unlikely(ctx->submitter_task != current)) {
+ /* maybe this is before any submissions */
+ return !ctx->submitter_task;
+ }
+ return true;
+}
+
#endif