From patchwork Fri Feb 3 04:36:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 52304 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp648389wrn; Thu, 2 Feb 2023 21:03:04 -0800 (PST) X-Google-Smtp-Source: AK7set8ZUmZAWJVdWVL5NvhdhR0//pYkqmv6UocD9qYVr/wkcSqAMvdq9Fu+5skcXpZ/sieVLbJ0 X-Received: by 2002:a05:6402:42ca:b0:4a2:47ac:c5a4 with SMTP id i10-20020a05640242ca00b004a247acc5a4mr12692910edc.23.1675400584454; Thu, 02 Feb 2023 21:03:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675400584; cv=none; d=google.com; s=arc-20160816; b=iCwHG9r4rSi5PBCOdO48szBHKgeWICZLgGyQERrZDNqJGxPehma0xWRyS6YrE07fRN pZXIlu2ea4nSkijt7eL7wZGoYaQYcYfvDQxcKzDEz2MYGDE+NplkncKCoHgOE87u8rbW Gj0xoesBslRgFXiCcql8GqLX0J1e3e0FbwJ0DBmOl3LuNPFoZls8HF56FN/r6iNaIOcO AfK8EgTQgWHIJMqB1Ir3s8ywJK2QXculyBRadGiR2Ggs10L8lBdaOp7wIJNp4tvu2sgC QjsbYeCJoaBfF1a49Np7MxVfica7r8UFknmy7wlw0NsSMaV+rLZcFAzm3ujST0aPMiO6 UgbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=CaG4IvFnfbDES3LqIwTSnlQbb1bUKki5x7areBpL6vA=; b=qUnEYl4DGuv3NZJl6Dl/AbQ5H2zGimmR+LZYh68u+kt7yBxP4/z3hrSehgH0Muxxs/ TNegdM/oUfVs8dW42ZLmiCbrTCYeHgLcHUMx1hs3GXpAvIUnVwVj9AmcLlPfa0Ln0kWX f1DL6oZjZTNY0MVXDP8jWOrz9TUdf3QWaHbMOO6AEl2ZUftodSyCB5IU1FUncqmFSbGl 5ljZZX5r+AwiPA3To0yK7eEwUfYY8VYBRY7sqY5M4vlgIcvThkW3QF2IpSACQwvLjkxw f4PMkOp0Vj4x0KHcoNZeq+wdECBb0nZXXrrHzy/ftMRC7n/lHVaCsEX1Kurax7/1rMj+ qTtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HsK1ZAGq; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds11-20020a0564021ccb00b0049e43606268si1855316edb.7.2023.02.02.21.02.30; Thu, 02 Feb 2023 21:03:04 -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=@kernel.org header.s=k20201202 header.b=HsK1ZAGq; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231732AbjBCEhE (ORCPT + 99 others); Thu, 2 Feb 2023 23:37:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbjBCEhB (ORCPT ); Thu, 2 Feb 2023 23:37:01 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 473D860CB9 for ; Thu, 2 Feb 2023 20:37:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D669C61D7D for ; Fri, 3 Feb 2023 04:36:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33A9CC433D2; Fri, 3 Feb 2023 04:36:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675399019; bh=vSXG2FNpbLvUQNLylcNUj1Px15+hEgLUz7VrP/XsoDQ=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=HsK1ZAGq++mEDNF+UNZz+3dH1nzLFgjDRsrh8UrC8+IpzA8LZuOCKcJ4b7tzcT9Wk JinU9YJPTRy9BZlDz+2QLRVYiNIDdldbf62jo7eSdaMnraafzvQAZo4/vWbO0LxrVx 6PsyZZRpVwn72JKjBPfh3sr7+2f42XR9bthXi70Ex9KaVmxigATVA+SGE5lqAHmTFA NYCtJ+eTIbYc9TnlMNGPtnGb9r/PhYUBqPFwApZfU6EdMJH6I2lNW4bJsWa0npDruu 7rntRxb2AAx49L0qR3brnZ84G/0yDwY34TwsujnM/JfkuLAxgvSMAwOwbweJPfgyJP 5luMMEvw/cL9Q== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id CAFA35C0DE7; Thu, 2 Feb 2023 20:36:58 -0800 (PST) Date: Thu, 2 Feb 2023 20:36:58 -0800 From: "Paul E. McKenney" To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, john.stultz@linaro.org, sboyd@kernel.org, corbet@lwn.net, Mark.Rutland@arm.com, maz@kernel.org, kernel-team@meta.com, neeraju@codeaurora.org, ak@linux.intel.com, feng.tang@intel.com, zhengjun.xing@intel.com, longman@redhat.com Subject: PATCH v2 clocksource 8/7] clocksource: Enable TSC watchdog checking of HPET and PMTMR only when requested Message-ID: <20230203043658.GA1513624@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20230125002708.GA1471122@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230125002708.GA1471122@paulmck-ThinkPad-P17-Gen-1> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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?1756784843134404231?= X-GMAIL-MSGID: =?utf-8?q?1756784843134404231?= Unconditionally enabling TSC watchdog checking of the HPET and PMTMR clocksources can degrade latency and performance. Therefore, provide a new "watchdog" option to the tsc= boot parameter that opts into such checking. Note that tsc=watchdog is overridden by a tsc=nowatchdog regardless of their relative positions in the list of boot parameters. Reported-by: Thomas Gleixner Reported-by: Waiman Long Signed-off-by: Paul E. McKenney Acked-by: Waiman Long diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 95f0d104c2322..7b4df6d89d3c3 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6373,6 +6373,12 @@ (HPET or PM timer) on systems whose TSC frequency was obtained from HW or FW using either an MSR or CPUID(0x15). Warn if the difference is more than 500 ppm. + [x86] watchdog: Use TSC as the watchdog clocksource with + which to check other HW timers (HPET or PM timer), but + only on systems where TSC has been deemed trustworthy. + This will be suppressed by an earlier tsc=nowatchdog and + can be overridden by a later tsc=nowatchdog. A console + message will flag any such suppression or overriding. tsc_early_khz= [X86] Skip early TSC calibration and use the given value instead. Useful when the early TSC frequency discovery diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index a5371c6d4b64b..306c233c98d84 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -294,6 +294,7 @@ __setup("notsc", notsc_setup); static int no_sched_irq_time; static int no_tsc_watchdog; +static int tsc_as_watchdog; static int __init tsc_setup(char *str) { @@ -303,10 +304,22 @@ static int __init tsc_setup(char *str) no_sched_irq_time = 1; if (!strcmp(str, "unstable")) mark_tsc_unstable("boot parameter"); - if (!strcmp(str, "nowatchdog")) + if (!strcmp(str, "nowatchdog")) { no_tsc_watchdog = 1; + if (tsc_as_watchdog) + pr_alert("%s: Overriding earlier tsc=watchdog with tsc=nowatchdog\n", + __func__); + tsc_as_watchdog = 0; + } if (!strcmp(str, "recalibrate")) tsc_force_recalibrate = 1; + if (!strcmp(str, "watchdog")) { + if (no_tsc_watchdog) + pr_alert("%s: tsc=watchdog overridden by earlier tsc=nowatchdog\n", + __func__); + else + tsc_as_watchdog = 1; + } return 1; } @@ -1192,7 +1205,8 @@ static void __init tsc_disable_clocksource_watchdog(void) bool tsc_clocksource_watchdog_disabled(void) { - return !(clocksource_tsc.flags & CLOCK_SOURCE_MUST_VERIFY); + return !(clocksource_tsc.flags & CLOCK_SOURCE_MUST_VERIFY) && + tsc_as_watchdog && !no_tsc_watchdog; } static void __init check_system_tsc_reliable(void)