From patchwork Mon Feb 13 18:48:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 56452 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2513329wrn; Mon, 13 Feb 2023 10:53:55 -0800 (PST) X-Google-Smtp-Source: AK7set9RxVNAkyeXM1zQSh7p6tkzuQX0LX7kASxKezjVnMZXq/mhD8IyhQb5mE60Qj8QTw7jPXka X-Received: by 2002:a50:d69e:0:b0:4ac:bbdb:462a with SMTP id r30-20020a50d69e000000b004acbbdb462amr8764995edi.14.1676314435494; Mon, 13 Feb 2023 10:53:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676314435; cv=none; d=google.com; s=arc-20160816; b=Di/65DdvcbK5M5nUZ/YlvsjH7H8tTiUyO9vUjcRqoK1VvmL8ZL+ACd+TtdYA5Iw7z4 oFf/DLDCpf7g6a1Fyb+x6yV89cv9lIEuXUftb1PKmR0USTIaABkDzwEEAXGkrTG4eSYO x2rjEY09elQoKyCD9z8/oV3o+muIDLRXd8R2/eAOhmkxY0maK64K6m8K8SJOOZEMpjC0 Pg8cHlxTVrX4PrDZwGFT3l1KWfFokkv5iGt78p3Ru03wzE0o2qb6vQWDpZR45qcjTtPp s6kPTT/xlt+g9uny3zBvb3Q8nhNuPVPCqf57nLlOM12Wu4p11GMo52d9SeYEE4mmJPzf ILLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=eS/JiuuqtXiw1NTI+j2SyVN5tbmyJPF5sj86ctZ/cyU=; b=oeMVcjHgFN0VOpNCHNNEUrnYSD0WhVtOZYLPG6Rs/b/PmFJMovo7hiDFMN5GL77DIq mZQu6c8aoxpSvGCVZFmLPDUjHcXJbg6QOqvjByp6GRPf2VU2bfU06mz+1gT9VNrwARcN 2ofdADp+R/5sMScHLMOMY23JkJGxVA0RqZyWzhj6lLKlgrrkk6mdezW30BpKV273jPcG ugnXMYTUs2Tk/HpsJKbSY96QAiOdirksgn/J1XFG4sVfDPfYIRJ4Vp19qmnqQiRVz0Gj /cUWvurynO7ZhVTPYg6v3t05UYf4lMDb0LOZxTg9ox6FldPrkSA5qBIytU78hlcOfMZ+ xuTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AFo2V4uV; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l24-20020aa7cad8000000b004a0e2b93456si14357170edt.456.2023.02.13.10.53.31; Mon, 13 Feb 2023 10:53:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AFo2V4uV; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230062AbjBMStC (ORCPT + 99 others); Mon, 13 Feb 2023 13:49:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229862AbjBMSsg (ORCPT ); Mon, 13 Feb 2023 13:48:36 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B665C1CAEC; Mon, 13 Feb 2023 10:48:35 -0800 (PST) Date: Mon, 13 Feb 2023 18:48:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1676314114; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eS/JiuuqtXiw1NTI+j2SyVN5tbmyJPF5sj86ctZ/cyU=; b=AFo2V4uVrT+j5jBY2rM373rmvEJZF41ubniCbrjWi/FjPbYfZmqqjjoufV3gl0BuC/YQwo 2BVC6YQUrowfn3QJPxwCp+TtL2nziY/xhs8VeH86+cHlMTunOAT2Xegr+xIgsJrGfoWZH3 TTkSdlW8qKyywQokoerD/ERGWX9FvVXp1wZxXt1D95ZfpkmU0v0Y3uhaZmkALB71Ztrr9L QLwSeGtqu9mxKjBQirW/AxNg1sfBjcsz3m7dlD5mK6fP6rSV2yCQ9sWPiCTF0sEncsKqi7 RJIEsahWs/KrwkSBRs3heu6vHzVlULGbvyZUlNB10zD4NUTcAdQoRCWVnhe9Jg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1676314114; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eS/JiuuqtXiw1NTI+j2SyVN5tbmyJPF5sj86ctZ/cyU=; b=jJAkY8Y0CSamjw/YqEiALEVwZ0VWHBz4eHkB/BfgerYoOdJ6WHY3UWk4/Xl4CSLi1MKMPj KS30a1S0umhDq3Cw== From: "tip-bot2 for Paul E. McKenney" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] clocksource: Loosen clocksource watchdog constraints Cc: "Paul E. McKenney" , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <167631411389.4906.18096787596269259442.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757743085437412024?= X-GMAIL-MSGID: =?utf-8?q?1757743085437412024?= The following commit has been merged into the timers/core branch of tip: Commit-ID: c37e85c135cead4256dc8860073c468d8925c3df Gitweb: https://git.kernel.org/tip/c37e85c135cead4256dc8860073c468d8925c3df Author: Paul E. McKenney AuthorDate: Tue, 06 Dec 2022 19:36:10 -08:00 Committer: Paul E. McKenney CommitterDate: Tue, 03 Jan 2023 20:43:45 -08:00 clocksource: Loosen clocksource watchdog constraints Currently, MAX_SKEW_USEC is set to 100 microseconds, which has worked reasonably well. However, NTP is willing to tolerate 500 microseconds of skew per second, and a clocksource that is good enough for NTP should be good enough for the clocksource watchdog. The watchdog's skew is controlled by MAX_SKEW_USEC and the CLOCKSOURCE_WATCHDOG_MAX_SKEW_US Kconfig option. However, these values are doubled before being associated with a clocksource's ->uncertainty_margin, and the ->uncertainty_margin values of the pair of clocksource's being compared are summed before checking against the skew. Therefore, set both MAX_SKEW_USEC and the default for the CLOCKSOURCE_WATCHDOG_MAX_SKEW_US Kconfig option to 125 microseconds of skew per second, resulting in 500 microseconds of skew per second in the clocksource watchdog's skew comparison. Suggested-by Rik van Riel Signed-off-by: Paul E. McKenney --- kernel/time/Kconfig | 6 +++++- kernel/time/clocksource.c | 15 +++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig index a41753b..bae8f11 100644 --- a/kernel/time/Kconfig +++ b/kernel/time/Kconfig @@ -200,10 +200,14 @@ config CLOCKSOURCE_WATCHDOG_MAX_SKEW_US int "Clocksource watchdog maximum allowable skew (in μs)" depends on CLOCKSOURCE_WATCHDOG range 50 1000 - default 100 + default 125 help Specify the maximum amount of allowable watchdog skew in microseconds before reporting the clocksource to be unstable. + The default is based on a half-second clocksource watchdog + interval and NTP's maximum frequency drift of 500 parts + per million. If the clocksource is good enough for NTP, + it is good enough for the clocksource watchdog! endmenu endif diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 4a2c3bb..a3d19f6 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -96,6 +96,11 @@ static int finished_booting; static u64 suspend_start; /* + * Interval: 0.5sec. + */ +#define WATCHDOG_INTERVAL (HZ >> 1) + +/* * Threshold: 0.0312s, when doubled: 0.0625s. * Also a default for cs->uncertainty_margin when registering clocks. */ @@ -106,11 +111,14 @@ static u64 suspend_start; * clocksource surrounding a read of the clocksource being validated. * This delay could be due to SMIs, NMIs, or to VCPU preemptions. Used as * a lower bound for cs->uncertainty_margin values when registering clocks. + * + * The default of 500 parts per million is based on NTP's limits. + * If a clocksource is good enough for NTP, it is good enough for us! */ #ifdef CONFIG_CLOCKSOURCE_WATCHDOG_MAX_SKEW_US #define MAX_SKEW_USEC CONFIG_CLOCKSOURCE_WATCHDOG_MAX_SKEW_US #else -#define MAX_SKEW_USEC 100 +#define MAX_SKEW_USEC (125 * WATCHDOG_INTERVAL / HZ) #endif #define WATCHDOG_MAX_SKEW (MAX_SKEW_USEC * NSEC_PER_USEC) @@ -140,11 +148,6 @@ static inline void clocksource_watchdog_unlock(unsigned long *flags) static int clocksource_watchdog_kthread(void *data); static void __clocksource_change_rating(struct clocksource *cs, int rating); -/* - * Interval: 0.5sec. - */ -#define WATCHDOG_INTERVAL (HZ >> 1) - static void clocksource_watchdog_work(struct work_struct *work) { /*