Skip to contentSkip to conversation

io_uring: update sq_thread_idle after ctx deleted

PATCH Applied Hao Xu 3 participants 4 messages Apr 24, 2021 – Apr 25, 2021

Subsystems (2)
lore
Share & tools
lore

Hao Xu

author
#0 lore raw

PATCH 1/1 io_uring: update sq_thread_idle after ctx deleted

we shall update sq_thread_idle anytime we do ctx deletion from ctx_list

Fixes 734551df6f9b ("io_uring: fix shared sqpoll cancellation hangs")
---
 fs/io_uring.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/io_uring.c +2 -1
index 40f38256499c..15f204274761 100644
@@ -8867,6 +8867,7 @@ static void io_sqpoll_cancel_cb(struct callback_head *cb)
 	if (sqd->thread)
 		io_uring_cancel_sqpoll(sqd);
 	list_del_init(&work->ctx->sqd_list);
+	io_sqd_update_thread_idle(sqd);
 	complete(&work->completion);
 }
 
@@ -8877,7 +8878,6 @@ static void io_sqpoll_cancel_sync(struct io_ring_ctx *ctx)
 	struct task_struct *task;
 
 	io_sq_thread_park(sqd);
-	io_sqd_update_thread_idle(sqd);
 	task = sqd->thread;
 	if (task) {
 		init_completion(&work.completion);
@@ -8886,6 +8886,7 @@ static void io_sqpoll_cancel_sync(struct io_ring_ctx *ctx)
 		wake_up_process(task);
 	} else {
 		list_del_init(&ctx->sqd_list);
+		io_sqd_update_thread_idle(sqd);
 	}
 	io_sq_thread_unpark(sqd);
 
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 1 line · Hao Xu

we shall update sq_thread_idle anytime we do ctx deletion from ctx_list

looks good, a nit below

Quoted 28 lines
Fixes 734551df6f9b ("io_uring: fix shared sqpoll cancellation hangs")
---
 fs/io_uring.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/io_uring.c +1 -1
index 40f38256499c..15f204274761 100644
@@ -8867,6 +8867,7 @@ static void io_sqpoll_cancel_cb(struct callback_head *cb)
 	if (sqd->thread)
 		io_uring_cancel_sqpoll(sqd);
 	list_del_init(&work->ctx->sqd_list);
+	io_sqd_update_thread_idle(sqd);
 	complete(&work->completion);
 }
 
@@ -8877,7 +8878,6 @@ static void io_sqpoll_cancel_sync(struct io_ring_ctx *ctx)
 	struct task_struct *task;
 
 	io_sq_thread_park(sqd);
-	io_sqd_update_thread_idle(sqd);
 	task = sqd->thread;
 	if (task) {
 		init_completion(&work.completion);

fs/io_uring.c static void io_sqpoll_cancel_sync(struct io_ring_ctx *ctx) · line 8889

Quoted 4 lines
fs/io_uring.c +1 -0
@@ -8886,6 +8886,7 @@ static void io_sqpoll_cancel_sync(struct io_ring_ctx *ctx)
 		wake_up_process(task);
 	} else {
 		list_del_init(&ctx->sqd_list);
+		io_sqd_update_thread_idle(sqd);

Not actually needed, it's already dying.

Quoted 4 lines
fs/io_uring.c +0 -0
 	}
 	io_sq_thread_unpark(sqd);
 
Signature · 1 line
Pavel Begunkov
author
#2 lore raw
Quoted 27 lines · Pavel Begunkov
Quoted 1 line · Hao Xu

we shall update sq_thread_idle anytime we do ctx deletion from ctx_list

looks good, a nit below

Quoted 22 lines
Fixes 734551df6f9b ("io_uring: fix shared sqpoll cancellation hangs")
---
  fs/io_uring.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
fs/io_uring.c +1 -0
index 40f38256499c..15f204274761 100644
@@ -8867,6 +8867,7 @@ static void io_sqpoll_cancel_cb(struct callback_head *cb)
  	if (sqd->thread)
  		io_uring_cancel_sqpoll(sqd);
  	list_del_init(&work->ctx->sqd_list);
+	io_sqd_update_thread_idle(sqd);
  	complete(&work->completion);
  }
 
@@ -8877,7 +8878,6 @@ static void io_sqpoll_cancel_sync(struct io_ring_ctx *ctx)
  	struct task_struct *task;
 
Quoted 13 lines

fs/io_uring.c static void io_sqpoll_cancel_sync(struct io_ring_ctx *ctx) · line 8889

Quoted 10 lines
fs/io_uring.c +1 -1
  	io_sq_thread_park(sqd);
-	io_sqd_update_thread_idle(sqd);
  	task = sqd->thread;
  	if (task) {
  		init_completion(&work.completion);
@@ -8886,6 +8886,7 @@ static void io_sqpoll_cancel_sync(struct io_ring_ctx *ctx)
  		wake_up_process(task);
  	} else {
  		list_del_init(&ctx->sqd_list);
+		io_sqd_update_thread_idle(sqd);

Not actually needed, it's already dying.

Yep, we could keep it since it's not in hot path.

Quoted 5 lines
Quoted 4 lines
fs/io_uring.c +0 -0
  	}
  	io_sq_thread_unpark(sqd);
 
maintainer Applied
#3 lore raw
In reply to Hao Xu
Quoted 1 line · Hao Xu

we shall update sq_thread_idle anytime we do ctx deletion from ctx_list

Applied, thanks.

Signature · 1 line
Jens Axboe