Skip to content

Commit 00ddff4

Browse files
committed
io-wq: ensure task is running before processing task_work
Mark the current task as running if we need to run task_work from the io-wq threads as part of work handling. If that is the case, then return as such so that the caller can appropriately loop back and reset if it was part of a going-to-sleep flush. Fixes: 3bfe610 ("io-wq: fork worker threads from original task") Signed-off-by: Jens Axboe <[email protected]>
1 parent 4db4b1a commit 00ddff4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/io-wq.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,16 @@ static struct io_wq_work *io_get_next_work(struct io_wqe *wqe)
386386
return NULL;
387387
}
388388

389-
static void io_flush_signals(void)
389+
static bool io_flush_signals(void)
390390
{
391391
if (unlikely(test_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL))) {
392+
__set_current_state(TASK_RUNNING);
392393
if (current->task_works)
393394
task_work_run();
394395
clear_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL);
396+
return true;
395397
}
398+
return false;
396399
}
397400

398401
static void io_assign_current_work(struct io_worker *worker,
@@ -499,7 +502,8 @@ static int io_wqe_worker(void *data)
499502
}
500503
__io_worker_idle(wqe, worker);
501504
raw_spin_unlock_irq(&wqe->lock);
502-
io_flush_signals();
505+
if (io_flush_signals())
506+
continue;
503507
ret = schedule_timeout(WORKER_IDLE_TIMEOUT);
504508
if (try_to_freeze() || ret)
505509
continue;

0 commit comments

Comments
 (0)