Skip to contentSkip to conversation

io_uring: clear IORING_SQ_NEED_WAKEUP for all ctxes accordingly when waken up

RFC PATCH In review Xiaoguang Wang 2 participants 2 messages Sep 13, 2020 – Sep 14, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 io_uring: clear IORING_SQ_NEED_WAKEUP for all ctxes accordingly when waken up

When poll thread is waken up, should clear all ctxes' IORING_SQ_NEED_WAKEUP flag, otherwise apps will always enter kernel to submit reqs.

Fixes df033a30aaee ("io_uring: set ctx need-wakeup flag when SQPOLL thread is going idle")
---
 fs/io_uring.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/io_uring.c +4 -2
index ae83d887c24d..9491f2040a93 100644
@@ -6849,12 +6849,14 @@ static int io_sq_thread(void *data)
 			io_run_task_work();
 			cond_resched();
 		} else if (ret == SQT_IDLE) {
-			list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
-				io_ring_set_wakeup_flag(ctx);
 			if (kthread_should_park())
 				continue;
+			list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
+				io_ring_set_wakeup_flag(ctx);
 			schedule();
 			start_jiffies = jiffies;
+			list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
+				io_ring_clear_wakeup_flag(ctx);
 		}
 	}
 
Signature · 1 line
2.17.2
maintainer
#1 lore raw
Quoted 2 lines · Xiaoguang Wang

When poll thread is waken up, should clear all ctxes' IORING_SQ_NEED_WAKEUP flag, otherwise apps will always enter kernel to submit reqs.

Thanks, I'm going to fold this in, as I folded in the referenced fix as well.

Signature · 1 line
Jens Axboe