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.
Unified · Split
| @@ -386,13 +386,16 @@ static struct io_wq_work *io_get_next_work(struct io_wqe *wqe) · 385 unmodified lines | |||
| 386 | return NULL; | 386 | return NULL; |
| 387 | } | 387 | } |
| 388 | 388 | ||
| 389 | static void io_flush_signals(void) | 389 | static bool io_flush_signals(void) |
| 390 | { | 390 | { |
| 391 | if (unlikely(test_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL))) { | 391 | if (unlikely(test_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL))) { |
| 392 | __set_current_state(TASK_RUNNING); | ||
| 392 | if (current->task_works) | 393 | if (current->task_works) |
| 393 | task_work_run(); | 394 | task_work_run(); |
| 394 | clear_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL); | 395 | clear_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL); |
| 396 | return true; | ||
| 395 | } | 397 | } |
| 398 | return false; | ||
| 396 | } | 399 | } |
| 397 | 400 | ||
| 398 | static void io_assign_current_work(struct io_worker *worker, | 401 | static void io_assign_current_work(struct io_worker *worker, |
| @@ -499,7 +502,8 @@ loop: · 100 unmodified lines | |||
| 499 | } | 502 | } |
| 500 | __io_worker_idle(wqe, worker); | 503 | __io_worker_idle(wqe, worker); |
| 501 | raw_spin_unlock_irq(&wqe->lock); | 504 | raw_spin_unlock_irq(&wqe->lock); |
| 502 | io_flush_signals(); | 505 | if (io_flush_signals()) |
| 506 | continue; | ||
| 503 | ret = schedule_timeout(WORKER_IDLE_TIMEOUT); | 507 | ret = schedule_timeout(WORKER_IDLE_TIMEOUT); |
| 504 | if (try_to_freeze() || ret) | 508 | if (try_to_freeze() || ret) |
| 505 | continue; | 509 | continue; |