Skip to content

Commit 46a525e

Browse files
committed
io_uring: don't gate task_work run on TIF_NOTIFY_SIGNAL
This isn't a reliable mechanism to tell if we have task_work pending, we really should be looking at whether we have any items queued. This is problematic if forward progress is gated on running said task_work. One such example is reading from a pipe, where the write side has been closed right before the read is started. The fput() of the file queues TWA_RESUME task_work, and we need that task_work to be run before ->release() is called for the pipe. If ->release() isn't called, then the read will sit forever waiting on data that will never arise. Fix this by io_run_task_work() so it checks if we have task_work pending rather than rely on TIF_NOTIFY_SIGNAL for that. The latter obviously doesn't work for task_work that is queued without TWA_SIGNAL. Reported-by: Christiano Haesbaert <[email protected]> Cc: [email protected] Link: axboe/liburing#665 Signed-off-by: Jens Axboe <[email protected]>
1 parent b000145 commit 46a525e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

io_uring/io_uring.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ static inline unsigned int io_sqring_entries(struct io_ring_ctx *ctx)
231231

232232
static inline int io_run_task_work(void)
233233
{
234-
if (test_thread_flag(TIF_NOTIFY_SIGNAL)) {
234+
if (task_work_pending(current)) {
235+
if (test_thread_flag(TIF_NOTIFY_SIGNAL))
236+
clear_notify_signal();
235237
__set_current_state(TASK_RUNNING);
236-
clear_notify_signal();
237-
if (task_work_pending(current))
238-
task_work_run();
238+
task_work_run();
239239
return 1;
240240
}
241241

0 commit comments

Comments
 (0)