public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH 5.12] io_uring: always go for cancellation spin on exec
@ 2021-03-27  9:59 Pavel Begunkov
  2021-03-29  0:12 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-03-27  9:59 UTC (permalink / raw)
  To: Jens Axboe, io-uring

Always try to do cancellation in __io_uring_task_cancel() at least once,
so it actually goes and cleans its sqpoll tasks (i.e. via
io_sqpoll_cancel_sync()), otherwise sqpoll task may submit new requests
after cancellation and it's racy for many reasons.

Fixes: 521d6a737a31c ("io_uring: cancel sqpoll via task_work")
Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 66ae46874d85..0bbfb05572d6 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -9004,6 +9004,8 @@ void __io_uring_task_cancel(void)
 
 	/* make sure overflow events are dropped */
 	atomic_inc(&tctx->in_idle);
+	__io_uring_files_cancel(NULL);
+
 	do {
 		/* read completions before cancelations */
 		inflight = tctx_inflight(tctx);
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 5.12] io_uring: always go for cancellation spin on exec
  2021-03-27  9:59 [PATCH 5.12] io_uring: always go for cancellation spin on exec Pavel Begunkov
@ 2021-03-29  0:12 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-03-29  0:12 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On 3/27/21 3:59 AM, Pavel Begunkov wrote:
> Always try to do cancellation in __io_uring_task_cancel() at least once,
> so it actually goes and cleans its sqpoll tasks (i.e. via
> io_sqpoll_cancel_sync()), otherwise sqpoll task may submit new requests
> after cancellation and it's racy for many reasons.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-29  0:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-27  9:59 [PATCH 5.12] io_uring: always go for cancellation spin on exec Pavel Begunkov
2021-03-29  0:12 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox