* [PATCH] io_uring: fix skipping disabling sqo on exec
@ 2021-01-16 23:37 Pavel Begunkov
2021-01-17 2:13 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Begunkov @ 2021-01-16 23:37 UTC (permalink / raw)
To: Jens Axboe, io-uring
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 <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
---
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);
@@ -9085,6 +9087,10 @@ void __io_uring_task_cancel(void)
/* make sure overflow events are dropped */
atomic_inc(&tctx->in_idle);
+ /* trigger io_disable_sqo_submit() */
+ if (tctx->sqpoll)
+ __io_uring_files_cancel(NULL);
+
do {
/* read completions before cancelations */
inflight = tctx_inflight(tctx);
--
2.24.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] io_uring: fix skipping disabling sqo on exec
2021-01-16 23:37 [PATCH] io_uring: fix skipping disabling sqo on exec Pavel Begunkov
@ 2021-01-17 2:13 ` Jens Axboe
2021-01-17 2:32 ` Pavel Begunkov
0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2021-01-17 2:13 UTC (permalink / raw)
To: Pavel Begunkov, io-uring
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 <[email protected]>
> Signed-off-by: Pavel Begunkov <[email protected]>
> ---
>
> 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.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] io_uring: fix skipping disabling sqo on exec
2021-01-17 2:13 ` Jens Axboe
@ 2021-01-17 2:32 ` Pavel Begunkov
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Begunkov @ 2021-01-17 2:32 UTC (permalink / raw)
To: Jens Axboe, io-uring
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 <[email protected]>
>> Signed-off-by: Pavel Begunkov <[email protected]>
>> ---
>>
>> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-17 2:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-16 23:37 [PATCH] io_uring: fix skipping disabling sqo on exec Pavel Begunkov
2021-01-17 2:13 ` Jens Axboe
2021-01-17 2:32 ` Pavel Begunkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox