Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5915501iob; Tue, 10 May 2022 06:39:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyv5nNyuPT59mJ2LbSIK7GlhWakRoeW0T08FJr0s1FhvLfFQegmVlVn9pcI8fKFABbM7eqQ X-Received: by 2002:a17:90a:930b:b0:1bf:ac1f:6585 with SMTP id p11-20020a17090a930b00b001bfac1f6585mr90568pjo.88.1652189941685; Tue, 10 May 2022 06:39:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652189941; cv=none; d=google.com; s=arc-20160816; b=MXbKCa6RjZrHvo7lNwCoOH/RdkTTQhcI8xgVc4sj9SfctbQ4roV9dJWECcWt/5wlk8 LCWJDa1EGNIVkg5l4Knzj3e3S6r+pm0yThKSbMsmU9gM2vWMRqOI6Q8EHmxS0X3wEPhM jjqWPZxCTD7oPRO9DffqTwVVzkXb/jGZb3eHZUsxGfoW1ynfQ2of2w2kRuYcl0IULdNF i4+UYAt5p4jQfCV/V2FLOdsasUmgKhCDRX/AFxkk2yWz5y0pSM7XkbdmnyRUJ7WJXvku OBH3cjIn8o/A0zJ+kPXNSL74fzJEMQmZSmhSPmy7rLRnTH2XQLRLdQH7HwI6qYLT8F2M DDDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id :mime-version:in-reply-to:references:cc:to:subject:from:date :dkim-signature; bh=itXK+rSLc1QihSjSoLaf7Q70y9HboDnIPkUMbBBhjnc=; b=TAym2dRzhOV0dmUJF9l8C4jBeeKyWIEpjItdzyjGpG6qpJW1RJTM4g6uIo+iWkO7U9 rDXLJDsrfmHMyjtItPWi0T/JP8m4QffX5VN4ZU1GgjVMudgDZWL+EdDDz+GY9bZhys+S huoedl8EBhgbN20B/HUPfCrCCxmnFcylsCPYXsCSawyh15WCRgbeiZOU1Ibyv3LRL52L BOKhsAKQumdzwjYhNO75t260sKPq4Z49rfWxpxNmd34DDAUCDGbXK0RhcPgNL87yrILY KjrBuFcJc0lxZdnjizfJruag4xeoW+tMW8BVpRlJjfFtUFpY+o44qx6MYA9aMo+UFdMA p2rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=P3c5o4HP; 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=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a170902bf4100b001589d3cab77si2940326pls.388.2022.05.10.06.38.46; Tue, 10 May 2022 06:39:01 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=P3c5o4HP; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240782AbiEJLU0 (ORCPT + 99 others); Tue, 10 May 2022 07:20:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235224AbiEJLUY (ORCPT ); Tue, 10 May 2022 07:20:24 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F579187D84 for ; Tue, 10 May 2022 04:16:28 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id t13so14368600pgn.8 for ; Tue, 10 May 2022 04:16:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:subject:to:cc:references:in-reply-to:mime-version :message-id:content-transfer-encoding; bh=itXK+rSLc1QihSjSoLaf7Q70y9HboDnIPkUMbBBhjnc=; b=P3c5o4HPneI+4Z47/3z0XyAHSGtCqvR/q0W4Nq/bwgtUcYH0Uy0Jd0jWxYk3ghvprP M0MmtF9mSteO6SObGM+KeBSRL/Th4Qu4mVxig0ifQZanH/5wImDWSHEoJhwowNlgQztq +fdho63/Z8O8Z+lPnO6hj/iRJm5XvhSDG1+J1izpbMQslnk4JvepsnrwPHrDGzxgn5TR vcaqxwR/GfEGirCr+I2kPVsku19Q8PppQZVPQfxI8KglDGZCMvJ1WONiiaZUQFmDypie o8tTi9z3MKBG9nHO9duRSWery/b9fOyTFXWIIbFoAAf1r0nJxinLTdMxGhUiFTNW8gL+ 06eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:subject:to:cc:references:in-reply-to :mime-version:message-id:content-transfer-encoding; bh=itXK+rSLc1QihSjSoLaf7Q70y9HboDnIPkUMbBBhjnc=; b=LVo31ge9PAqimJOLJlyRFiIbB1nszFVJZTHt+pJYjjE9xGq7RhyB42iuD1ILlNecSI GrTLirahPvw1Vym3k813AY81OmvR6Dju9pJbMO2InAmM9+IvFeSUYVLaG9eIwTTRFqAu dby2rbYnDMwILYBf4z9t3dOGjYSKlw2kB/tgD/buONGHu7wuqvP0m01c/+iUyp5iPnPy kC9Af17zdN2RYm+joxsmuJnS5bv+cUFYh4i3i+SXbAlMbWAcacIUnoeNfUoqwXXYu9v1 PXgLG2tgPD6zdSofGmMQRtTSD74CSd4S+sQ37fH92mLVyvU0vj0EWhDLGSCYpn8CQa3U VhLg== X-Gm-Message-State: AOAM530b5BLlcn+Ge3R3suSYE3hM4kkUeW+cbMmlEeqyCDhd84uOdpay w3sslYpfjGHrSXWYJlOxhWw= X-Received: by 2002:a05:6a00:21c2:b0:4fe:81f:46c7 with SMTP id t2-20020a056a0021c200b004fe081f46c7mr19960372pfj.5.1652181387580; Tue, 10 May 2022 04:16:27 -0700 (PDT) Received: from localhost (193-116-127-232.tpgi.com.au. [193.116.127.232]) by smtp.gmail.com with ESMTPSA id z29-20020aa79f9d000000b0050dc7628170sm10462375pfr.74.2022.05.10.04.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 04:16:26 -0700 (PDT) Date: Tue, 10 May 2022 21:16:21 +1000 From: Nicholas Piggin Subject: Re: [PATCH v6 28/29] x86/tsc: Restart NMI watchdog after refining tsc_khz To: Ricardo Neri , Thomas Gleixner , x86@kernel.org Cc: Andi Kleen , Andrew Morton , Lu Baolu , David Woodhouse , Stephane Eranian , iommu@lists.linux-foundation.org, Joerg Roedel , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "Ravi V. Shankar" , Ricardo Neri , Suravee Suthikulpanit , Tony Luck References: <20220506000008.30892-1-ricardo.neri-calderon@linux.intel.com> <20220506000008.30892-29-ricardo.neri-calderon@linux.intel.com> In-Reply-To: <20220506000008.30892-29-ricardo.neri-calderon@linux.intel.com> MIME-Version: 1.0 Message-Id: <1652180070.1r874kr0tg.astroid@bobo.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Excerpts from Ricardo Neri's message of May 6, 2022 10:00 am: > The HPET hardlockup detector relies on tsc_khz to estimate the value of > that the TSC will have when its HPET channel fires. A refined tsc_khz > helps to estimate better the expected TSC value. >=20 > Using the early value of tsc_khz may lead to a large error in the expecte= d > TSC value. Restarting the NMI watchdog detector has the effect of kicking > its HPET channel and make use of the refined tsc_khz. >=20 > When the HPET hardlockup is not in use, restarting the NMI watchdog is > a noop. >=20 > Cc: Andi Kleen > Cc: Stephane Eranian > Cc: "Ravi V. Shankar" > Cc: iommu@lists.linux-foundation.org > Cc: linuxppc-dev@lists.ozlabs.org > Cc: x86@kernel.org > Signed-off-by: Ricardo Neri > --- > Changes since v5: > * Introduced this patch >=20 > Changes since v4 > * N/A >=20 > Changes since v3 > * N/A >=20 > Changes since v2: > * N/A >=20 > Changes since v1: > * N/A > --- > arch/x86/kernel/tsc.c | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 > diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c > index cafacb2e58cc..cc1843044d88 100644 > --- a/arch/x86/kernel/tsc.c > +++ b/arch/x86/kernel/tsc.c > @@ -1386,6 +1386,12 @@ static void tsc_refine_calibration_work(struct wor= k_struct *work) > /* Inform the TSC deadline clockevent devices about the recalibration *= / > lapic_update_tsc_freq(); > =20 > + /* > + * If in use, the HPET hardlockup detector relies on tsc_khz. > + * Reconfigure it to make use of the refined tsc_khz. > + */ > + lockup_detector_reconfigure(); I don't know if the API is conceptually good. You change something that the lockup detector is currently using,=20 *while* the detector is running asynchronously, and then reconfigure it. What happens in the window? If this code is only used for small adjustments maybe it does not really matter but in principle it's a bad API to export. lockup_detector_reconfigure as an internal API is okay because it reconfigures things while the watchdog is stopped [actually that looks untrue for soft dog which uses watchdog_thresh in is_softlockup(), but that should be fixed]. You're the arch so you're allowed to stop the watchdog and configure it, e.g., hardlockup_detector_perf_stop() is called in arch/. So you want to disable HPET watchdog if it was enabled, then update wherever you're using tsc_khz, then re-enable. Thanks, Nick