[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181112185651.17138-1-mzhivich@akamai.com>
Date: Mon, 12 Nov 2018 13:56:51 -0500
From: Michael Zhivich <mzhivich@...mai.com>
To: linux-kernel@...r.kernel.org
Cc: omosnace@...hat.com, arnd@...db.de, jason.wessel@...driver.com,
john.stultz@...aro.org, Michael Zhivich <mzhivich@...mai.com>
Subject: [PATCH] Revert "clocksource: Make clocksource validation work for all clocksources"
Revert commit 1f45f1f33c8c ("clocksource: Make clocksource validation work
for all clocksources") to restore correct clocksource_delta() computation
for clocksources that wrap frequently, while retaining the check for tsc
drifting.
Truncating result of clocksource_delta() to 0 causes incorrect behavior for
clocksources that wrap frequently (e.g. acpi_pm which is only 24-bit wide).
In particular, large time deltas (e.g. last = 0x000000, now = 0x800000)
will be incorrectly computed as 0.
If acpi_pm is used as the clocksource watchdog, and machine is under heavy
load, the time period for the watchdog check may be significantly longer
than the requested 0.5 seconds. If the watchdog check is delayed by 2
seconds (observed behavior), then acpi_pm time delta will be
2.5 sec * 3579545 ticks/sec = 8948863 = 0x888c3f
which will be treated as negative and truncated to 0. This behavior will
cause tsc to be incorrectly declared unstable in clocksource_watchdog(), as
it no longer agrees with acpi_pm.
Signed-off-by: Michael Zhivich <mzhivich@...mai.com>
---
kernel/time/timekeeping_internal.h | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/kernel/time/timekeeping_internal.h b/kernel/time/timekeeping_internal.h
index bcbb52db2256..21463e20d008 100644
--- a/kernel/time/timekeeping_internal.h
+++ b/kernel/time/timekeeping_internal.h
@@ -18,11 +18,7 @@ static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
{
u64 ret = (now - last) & mask;
- /*
- * Prevent time going backwards by checking the MSB of mask in
- * the result. If set, return 0.
- */
- return ret & ~(mask >> 1) ? 0 : ret;
+ return (s64) ret > 0 ? ret : 0;
}
#else
static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
--
2.19.1
Powered by blists - more mailing lists