public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH 5.14] io_uring: pin ctx on fallback execution
@ 2021-08-17 21:36 Pavel Begunkov
  2021-08-17 22:06 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-08-17 21:36 UTC (permalink / raw)
  To: Jens Axboe, io-uring

Pin ring in io_fallback_req_func() by briefly elevating ctx->refs in
case any task_work handler touches ctx after releasing a request.

Fixes: 9011bf9a13e3b ("io_uring: fix stuck fallback reqs")
Signed-off-by: Pavel Begunkov <[email protected]>
---

p.s. I had been considering back then but don't remember why it was
dropped. Just be extra careful to not regress in 5.14

 fs/io_uring.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 6a092a534d2b..979941bcd15a 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2477,8 +2477,10 @@ static void io_fallback_req_func(struct work_struct *work)
 	struct llist_node *node = llist_del_all(&ctx->fallback_llist);
 	struct io_kiocb *req, *tmp;
 
+	percpu_ref_get(&ctx->refs);
 	llist_for_each_entry_safe(req, tmp, node, io_task_work.fallback_node)
 		req->io_task_work.func(req);
+	percpu_ref_put(&ctx->refs);
 }
 
 static void __io_complete_rw(struct io_kiocb *req, long res, long res2,
-- 
2.32.0


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

* Re: [PATCH 5.14] io_uring: pin ctx on fallback execution
  2021-08-17 21:36 [PATCH 5.14] io_uring: pin ctx on fallback execution Pavel Begunkov
@ 2021-08-17 22:06 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-08-17 22:06 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On 8/17/21 3:36 PM, Pavel Begunkov wrote:
> Pin ring in io_fallback_req_func() by briefly elevating ctx->refs in
> case any task_work handler touches ctx after releasing a request.

Applied, thanks.

-- 
Jens Axboe


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

end of thread, other threads:[~2021-08-17 22:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-17 21:36 [PATCH 5.14] io_uring: pin ctx on fallback execution Pavel Begunkov
2021-08-17 22:06 ` Jens Axboe

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