From 5504fc757c43350bb9e6581f0bcf1f8ddf9706a0 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sat, 30 Jan 2021 21:15:48 +0100 Subject: [PATCH] intel_cstates: ignore negative time-delta values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I have no idea why this can happen or if there is a deeper problem. Should fix #16546. Change-Id: Ia160e293eabefae636ce4c861864c99b0aaa68db Reviewed-on: https://review.haiku-os.org/c/haiku/+/3717 Reviewed-by: Jérôme Duval --- .../kernel/power/cpuidle/intel_cstates/intel_cstates.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/power/cpuidle/intel_cstates/intel_cstates.cpp b/src/add-ons/kernel/power/cpuidle/intel_cstates/intel_cstates.cpp index 5a6b5440ba..f3ddadeabe 100644 --- a/src/add-ons/kernel/power/cpuidle/intel_cstates/intel_cstates.cpp +++ b/src/add-ons/kernel/power/cpuidle/intel_cstates/intel_cstates.cpp @@ -100,7 +100,9 @@ cstates_idle(void) bigtime_t delta = system_time() - start; locker.Unlock(); - sIdleTime[cpu] = (idleTime + delta) / 2; + // Negative delta shouldn't happen, but apparently it does... + if (delta >= 0) + sIdleTime[cpu] = (idleTime + delta) / 2; }