Skip to contentSkip to conversation

io_uring/sqpoll: ensure that normal task_work is also run timely

PATCH New Jens Axboe 1 participant 1 message May 21, 2024 io_uring

lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH v2 1/1 io_uring/sqpoll: ensure that normal task_work is also run timely

With the move to private task_work, SQPOLL neglected to also run the normal task_work, if any is pending. This will eventually get run, but we should run it with the private task_work to ensure that things like a final fput() is processed in a timely fashion.

---

V2: move the task_work_run() section so we're always guaranteed it
runs after any task_work. Ran the previous test cases again, both the yarn based one and the liburing test case, and they still work as they should. Previously, if we had a retry condition due to being flooded with task_work, then we'd not run the kernel side task_work.

io_uring/sqpoll.c +4 -2
index 554c7212aa46..b3722e5275e7 100644
@@ -238,11 +238,13 @@ static unsigned int io_sq_tw(struct llist_node **retry_list, int max_entries)
 	if (*retry_list) {
 		*retry_list = io_handle_tw_list(*retry_list, &count, max_entries);
 		if (count >= max_entries)
-			return count;
+			goto out;
 		max_entries -= count;
 	}
-
 	*retry_list = tctx_task_work_run(tctx, max_entries, &count);
+out:
+	if (task_work_pending(current))
+		task_work_run();
 	return count;
 }
 
Signature · 1 line
Jens Axboe