Skip to contentSkip to conversation

io_uring: kill tw-related outdated comments

PATCH In review Pavel Begunkov 2 participants 2 messages Nov 17, 2022 io_uring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 io_uring: kill tw-related outdated comments

task_work fallback is executed from a workqueue, so current and req->task are not necessarily the same. It's still safe to poke into it as the request holds a task_struct reference.

---
 io_uring/io_uring.c | 2 +-
 io_uring/poll.c     | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)
io_uring/io_uring.c +1 -1
index 94329c1ce91d..5a8a43fb6750 100644
@@ -1249,7 +1249,7 @@ static void io_req_task_cancel(struct io_kiocb *req, bool *locked)
 void io_req_task_submit(struct io_kiocb *req, bool *locked)
 {
 	io_tw_lock(req->ctx, locked);
-	/* req->task == current here, checking PF_EXITING is safe */
+
 	if (likely(!(req->task->flags & PF_EXITING)))
 		io_queue_sqe(req);
 	else
io_uring/poll.c +0 -1
index 2830b7daf952..5d4a0a4a379a 100644
@@ -214,7 +214,6 @@ static int io_poll_check_events(struct io_kiocb *req, bool *locked)
 	struct io_ring_ctx *ctx = req->ctx;
 	int v, ret;
 
-	/* req->task == current here, checking PF_EXITING is safe */
 	if (unlikely(req->task->flags & PF_EXITING))
 		return -ECANCELED;
 
Signature · 1 line
2.38.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Pavel Begunkov

task_work fallback is executed from a workqueue, so current and req->task are not necessarily the same. It's still safe to poke into it as the request holds a task_struct reference.

Makes sense to me. Feel free to add

Quoted 31 lines
---
 io_uring/io_uring.c | 2 +-
 io_uring/poll.c     | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)
io_uring/io_uring.c +1 -1
index 94329c1ce91d..5a8a43fb6750 100644
@@ -1249,7 +1249,7 @@ static void io_req_task_cancel(struct io_kiocb *req, bool *locked)
 void io_req_task_submit(struct io_kiocb *req, bool *locked)
 {
 	io_tw_lock(req->ctx, locked);
-	/* req->task == current here, checking PF_EXITING is safe */
+
 	if (likely(!(req->task->flags & PF_EXITING)))
 		io_queue_sqe(req);
 	else
io_uring/poll.c +0 -1
index 2830b7daf952..5d4a0a4a379a 100644
@@ -214,7 +214,6 @@ static int io_poll_check_events(struct io_kiocb *req, bool *locked)
 	struct io_ring_ctx *ctx = req->ctx;
 	int v, ret;
 
-	/* req->task == current here, checking PF_EXITING is safe */
 	if (unlikely(req->task->flags & PF_EXITING))
 		return -ECANCELED;
Signature · 1 line
Gabriel Krisman Bertazi