io-wq: don't resched if there is no work
authorPavel Begunkov <asml.silence@gmail.com>
Fri, 13 Mar 2020 21:31:03 +0000 (00:31 +0300)
committerJens Axboe <axboe@kernel.dk>
Sat, 14 Mar 2020 23:02:26 +0000 (17:02 -0600)
This little tweak restores the behaviour that was before the recent
io_worker_handle_work() optimisation patches. It makes the function do
cond_resched() and flush_signals() only if there is an actual work to
execute.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io-wq.c

index 0e7c627..8afe556 100644 (file)
@@ -458,10 +458,12 @@ static void io_impersonate_work(struct io_worker *worker,
 static void io_assign_current_work(struct io_worker *worker,
                                   struct io_wq_work *work)
 {
-       /* flush pending signals before assigning new work */
-       if (signal_pending(current))
-               flush_signals(current);
-       cond_resched();
+       if (work) {
+               /* flush pending signals before assigning new work */
+               if (signal_pending(current))
+                       flush_signals(current);
+               cond_resched();
+       }
 
        spin_lock_irq(&worker->lock);
        worker->cur_work = work;