From 59b9b52aafcba9847df3791c525fac03c3caec3e Mon Sep 17 00:00:00 2001 From: Pawel Dziepak Date: Mon, 20 Jan 2014 03:14:56 +0100 Subject: [PATCH] scheduler: system_time() may be unreliable On multisocket systems as well as under virtual machines logical CPUs may use separate TSC. We could attempt to synchronize them what probably would solve problems on multisocket systems. Unfortunately, when running under hypervisor there is still a chance that TSC will get out of sync again (e.g. cpufreq enabled on host when there is no invariant TSC). As long as we use RDTSC as our main time source the scheduler must accept the fact that time may go backwards (what isn't really a serious problem). --- src/system/kernel/scheduler/scheduler_thread.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/system/kernel/scheduler/scheduler_thread.h b/src/system/kernel/scheduler/scheduler_thread.h index b5fa05cff3..200266c8b8 100644 --- a/src/system/kernel/scheduler/scheduler_thread.h +++ b/src/system/kernel/scheduler/scheduler_thread.h @@ -394,8 +394,7 @@ ThreadData::Enqueue() SCHEDULER_ENTER_FUNCTION(); if (!fReady) { - ASSERT(system_time() - fWentSleep >= 0); - if (gTrackCoreLoad) { + if (gTrackCoreLoad && system_time() - fWentSleep > 0) { fMeasureAvailableTime += system_time() - fWentSleep; fCore->UpdateLoad(fNeededLoad);