]> git.baikalelectronics.ru Git - kernel.git/commitdiff
io-wq: ensure task is running before processing task_work
authorJens Axboe <axboe@kernel.dk>
Sun, 21 Mar 2021 13:06:56 +0000 (07:06 -0600)
committerJens Axboe <axboe@kernel.dk>
Sun, 21 Mar 2021 15:41:14 +0000 (09:41 -0600)
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: 869731a7cd2f ("io-wq: fork worker threads from original task")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io-wq.c

index e05f996d088f17437834bcb96f4987d257773ab0..3dc10bfd8c3baa4a7130ab9caf6cdbf90cf5bd84 100644 (file)
@@ -386,13 +386,16 @@ static struct io_wq_work *io_get_next_work(struct io_wqe *wqe)
        return NULL;
 }
 
-static void io_flush_signals(void)
+static bool io_flush_signals(void)
 {
        if (unlikely(test_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL))) {
+               __set_current_state(TASK_RUNNING);
                if (current->task_works)
                        task_work_run();
                clear_tsk_thread_flag(current, TIF_NOTIFY_SIGNAL);
+               return true;
        }
+       return false;
 }
 
 static void io_assign_current_work(struct io_worker *worker,
@@ -499,7 +502,8 @@ loop:
                }
                __io_worker_idle(wqe, worker);
                raw_spin_unlock_irq(&wqe->lock);
-               io_flush_signals();
+               if (io_flush_signals())
+                       continue;
                ret = schedule_timeout(WORKER_IDLE_TIMEOUT);
                if (try_to_freeze() || ret)
                        continue;