From 3142fb6996948dd5e539ddcb56b0b81fe223cd26 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 11 Jul 2018 21:53:44 -0400 Subject: [PATCH] scheduler: Fix setting priorities following the penalty cancellation changes. Before hrev46809, the "thread->priority = priority" line was below this check, and so all was well. But that commit moved the line to its present location, which means ever since then, the following code which updates CPU entries, scheduler listeners, etc. has never been run. On my VMware instance (which is probably pretty affected by the host system and thus not the greatest performance test), "time jam -j2 HaikuDepot" decreased from 46.0s real to 43.3s real, 52.3s user to 48.1s user, 12.1s sys to 12.2s sys. So this seems to make some sort of impact. Spotted by Fishpond in #10454 and confirmed by korli, but somehow neither of them followed up on that in the 4.5 years since... --- src/system/kernel/scheduler/scheduler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/scheduler/scheduler.cpp b/src/system/kernel/scheduler/scheduler.cpp index 27022e371c..f7fca91256 100644 --- a/src/system/kernel/scheduler/scheduler.cpp +++ b/src/system/kernel/scheduler/scheduler.cpp @@ -184,8 +184,8 @@ scheduler_set_thread_priority(Thread *thread, int32 priority) thread->priority = priority; threadData->CancelPenalty(); - if (priority == thread->priority) - return thread->priority; + if (priority == oldPriority) + return oldPriority; if (thread->state != B_THREAD_READY) { if (thread->state == B_THREAD_RUNNING) {