From 5a8fe19382633008db51ee292bdcf8b8edca6ab0 Mon Sep 17 00:00:00 2001 From: Pavel Begunkov Date: Sat, 14 Mar 2020 00:31:03 +0300 Subject: [PATCH] io-wq: don't resched if there is no work to #28170604 commit d78298e73a3443a3c1766fa89f5370f52a4efd94 upstream 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 Signed-off-by: Jens Axboe Acked-by: Joseph Qi Signed-off-by: Xiaoguang Wang --- fs/io-wq.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/io-wq.c b/fs/io-wq.c index 5b45c936fcc5..4f9ce90355e9 100644 --- a/fs/io-wq.c +++ b/fs/io-wq.c @@ -459,10 +459,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; -- GitLab