On 17/01/2021 02:13, Jens Axboe wrote: > On 1/16/21 4:37 PM, Pavel Begunkov wrote: >> If there are no requests at the time __io_uring_task_cancel() is called, >> tctx_inflight() returns zero and and it terminates not getting a chance >> to go through __io_uring_files_cancel() and do >> io_disable_sqo_submit(). And we absolutely want them disabled by the >> time cancellation ends. >> >> Also a fix potential false positive warning because of ctx->sq_data >> check before io_disable_sqo_submit(). >> >> Reported-by: Jens Axboe <axboe@xxxxxxxxx> >> Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> >> --- >> >> To not grow diffstat now will be cleaned for-next >> >> fs/io_uring.c | 8 +++++++- >> 1 file changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/fs/io_uring.c b/fs/io_uring.c >> index d494c4269fc5..0d50845f1f3f 100644 >> --- a/fs/io_uring.c >> +++ b/fs/io_uring.c >> @@ -8937,10 +8937,12 @@ static void io_uring_cancel_task_requests(struct io_ring_ctx *ctx, >> { >> struct task_struct *task = current; >> >> - if ((ctx->flags & IORING_SETUP_SQPOLL) && ctx->sq_data) { >> + if (ctx->flags & IORING_SETUP_SQPOLL) { >> /* for SQPOLL only sqo_task has task notes */ >> WARN_ON_ONCE(ctx->sqo_task != current); >> io_disable_sqo_submit(ctx); >> + } >> + if ((ctx->flags & IORING_SETUP_SQPOLL) && ctx->sq_data) { >> task = ctx->sq_data->thread; >> atomic_inc(&task->io_uring->in_idle); >> io_sq_thread_park(ctx->sq_data); > > Maybe just nest that inside? > > if (ctx->flags & IORING_SETUP_SQPOLL) { > /* for SQPOLL only sqo_task has task notes */ > WARN_ON_ONCE(ctx->sqo_task != current); > io_disable_sqo_submit(ctx); > if (ctx->sq_data) { > ... > } > } > > That'd look a bit cleaner imho. second thought, it can't even happen because if not set we failed during creation, and it has its own disable hooks. sent v2 without that part -- Pavel Begunkov