From 8234cb87d8de718a3654bcbf5e10fb137406848c Mon Sep 17 00:00:00 2001 From: Timo Kokkonen Date: Sat, 21 Nov 2020 11:34:59 +0200 Subject: [PATCH] process: Always kick job scheduler when a worker finishes If we happen to have a very long running job, it is not desired that all other jobs remain stuck waiting this job to complete. This can happen if we first start all jobs, causing the scheduler to wait indefinitely for a "kick", then the last job takes forever to finish. To fix this, every time a job finishes, it is better to reschedule the job poller in case new job has become schedulable. Signed-off-by: Timo Kokkonen --- process.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/process.c b/process.c index 2f5bccd..12b77aa 100644 --- a/process.c +++ b/process.c @@ -134,15 +134,17 @@ out_unlock: * ensures next time we start spawning worker threads * the first thread will have number zero on its name. */ - if (!workers_active) { + if (!workers_active) worker_count = 0; - /* - * Kick the job poller, just to print the time of next - * update on the logs - */ - notify_job_request(); - } + /* + * Kick the job poller. If all jobs were active at this point + * the scheduler thread will wait indefinitely until someone + * tells it to do something. We may now know when next job is + * available, so it is better for the scheduler to recalculate + * its sleep time. + */ + notify_job_request(); mutex_unlock(&work_stats_mutex); -- 2.45.0