Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755341AbcDLA6D (ORCPT ); Mon, 11 Apr 2016 20:58:03 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:3402 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754196AbcDLA6B (ORCPT ); Mon, 11 Apr 2016 20:58:01 -0400 From: Shaohua Li To: lkml CC: Thomas Gleixner , John Stultz , Subject: [RFC 2/2] time: double check if watchdog clocksource is correct Date: Mon, 11 Apr 2016 17:57:57 -0700 Message-ID: <984ee7ee5ba91bdaa155a16e741f5b83d70233d2.1460422356.git.shli@fb.com> X-Mailer: git-send-email 2.8.0.rc2 In-Reply-To: <09c4f19409012995595db6fd0a12f326c292af1a.1460422356.git.shli@fb.com> References: <09c4f19409012995595db6fd0a12f326c292af1a.1460422356.git.shli@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-04-12_01:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1613 Lines: 38 We use watchdog clocksource to detect unstable clocksource. This assumes watchdog clocksource is correct. But it's possible watchdog clocksource is crappy, please see previous patch. Double check if watchdog interval is too long and bypass potential wrong watchdog clocksource. Signed-off-by: Shaohua Li --- kernel/time/clocksource.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 56ece14..36aff4e 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -122,9 +122,10 @@ static int clocksource_watchdog_kthread(void *data); static void __clocksource_change_rating(struct clocksource *cs, int rating); /* - * Interval: 0.5sec Threshold: 0.0625s + * Interval: 0.5sec, Max Interval: 0.75sec, Threshold: 0.0625s */ #define WATCHDOG_INTERVAL (HZ >> 1) +#define WATCHDOG_MAX_INTERVAL ((NSEC_PER_SEC >> 1) + (NSEC_PER_SEC >> 2)) #define WATCHDOG_THRESHOLD (NSEC_PER_SEC >> 4) static void clocksource_watchdog_work(struct work_struct *work) @@ -217,7 +218,8 @@ static void clocksource_watchdog(unsigned long data) continue; /* Check the deviation from the watchdog clocksource. */ - if (abs(cs_nsec - wd_nsec) > WATCHDOG_THRESHOLD) { + if (abs(cs_nsec - wd_nsec) > WATCHDOG_THRESHOLD && + wd_nsec < WATCHDOG_MAX_INTERVAL) { pr_warn("timekeeping watchdog on CPU%d: Marking clocksource '%s' as unstable because the skew is too large:\n", smp_processor_id(), cs->name); pr_warn(" '%s' wd_now: %llx wd_last: %llx mask: %llx\n", -- 2.8.0.rc2