Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4971300iob; Mon, 9 May 2022 06:04:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwT1LQ2cXFvScT61UFKA1W3p2gDnAERUrKV78BwjhWjsx9/DWyoxFVgZvb3cID7XyKoi4Y X-Received: by 2002:a63:6886:0:b0:3c5:11f4:f055 with SMTP id d128-20020a636886000000b003c511f4f055mr13303055pgc.44.1652101443584; Mon, 09 May 2022 06:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652101443; cv=none; d=google.com; s=arc-20160816; b=q0TJ24EBZHixYwlyL6gwe5+PiEj4Y68sAZUgLzSAWykp30slZjcbp5xp4DPpZku0At 4vyKUnh/WKL48rfvfp0IqVqCv1DwxDI0xVJtWLd1R+tyN7RjZtvCE+Kz+81QJEYA+wQM TW74594b4gLHYU6MD9G42EJrIpIDxG2+yqO9JwtaxZHvrgdA3D8qdbKu+sMXkrT3G/0s 2+FV+pMVzO9uT41EukgOMjFwN0MfeRtkQNDISIL/76yd3upnwJg3MbO1O82mqjMyeKW1 MF0DsxJhuyZGLmyPA/8Lg6C4PzJ3XUx2njilXkGRn4VO+tnF/Eo8KJ+8OOBc5fOeFouk ZHfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=x/zYYkDp46T56YvlQm4HC+fLbVjJRANPrhmHN/ReK5Q=; b=V2JRczeWxAardJBXd0z7H7uNEgSezq94wz7pocO32ORS2WkdF+OdKrcl7NiCVKgLkr b49XntgQSM/uM2YNyl4XOx/GU/Majj7d5NZvTvH2/UN7HiU8AT23xaQpglLrhwyHmj0/ NBLCok6zq9v4vdnwcM7uMVGMg5CBQ6iJ3DqzjdMv4dkiYyXk0F8PKgHLBclHgvLbnZoL 9a6shyVbtCkZYhWAmLAN6dJNW4SHglr1dPMEq8FaMaU3ZrTWsPKSF2NHrLWHQzJ/DHBu lj3XZ21cAyYHFjVGC+xPY4TNNUqyVQSAwBet/lZs3Q6Xe4A4V+mNv73cqymAMYSUYivc E9Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NZ0CicO5; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=ImyS8Lgq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 13-20020a170902c20d00b001548c7c077fsi10874983pll.454.2022.05.09.06.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:04:03 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NZ0CicO5; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=ImyS8Lgq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2F4A62A3BE7; Mon, 9 May 2022 06:03:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235065AbiEINHW (ORCPT + 99 others); Mon, 9 May 2022 09:07:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234704AbiEINHU (ORCPT ); Mon, 9 May 2022 09:07:20 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A3D02A3BDC for ; Mon, 9 May 2022 06:03:27 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1652101406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=x/zYYkDp46T56YvlQm4HC+fLbVjJRANPrhmHN/ReK5Q=; b=NZ0CicO5dQCrwn1cQlEBnFXfBkpjn7ZGBBw5h5B90dBKvV31xThEGM73JjR9KwKmWlFzvk P/t4wgd0d6X6NmXaH/Ferau02+JWlGQb1/w4e9SXAXLnH3eeHVbGUmamyt8uzxWG7GE4x0 VDMzif/2TmU1PZ1m5m0Jto9ZcjbawHDJAGt36nwDZgXyTeZ7+Pxu8y5FNgJ98q3pzI5+mY KYa+M1xJNiSaNVrhpfmDlQnx0RxBeqe5IHjYdzTMJaIl/iwY+5dqtwqV/AGkaA1/l7MHY1 +IOwY20s64tr64xjeFCx1l4ms1b02PRwvAWanFoE8buoGv6lp+GtxJMR+9CnKg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1652101406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=x/zYYkDp46T56YvlQm4HC+fLbVjJRANPrhmHN/ReK5Q=; b=ImyS8LgqMEt8qLtMCih5THBPRvQBDfT0bn+sgJLLGSfMcLuL6PrBEAVB9RBwU3sutiEusc Z7Lx+Ub6dIK+fACA== To: Feng Tang Cc: Peter Zijlstra , Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Jonathan Corbet , x86@kernel.org, linux-kernel@vger.kernel.org, paulmck@kernel.org, rui.zhang@intel.com, len.brown@intel.com, tim.c.chen@intel.com Subject: Re: [PATCH] x86/tsc: Add option to force HW timer based recalibration In-Reply-To: <20220509112235.GD40730@shbuild999.sh.intel.com> References: <20220508144733.91343-1-feng.tang@intel.com> <20220509045839.GA40730@shbuild999.sh.intel.com> <20220509071652.GE76023@worktop.programming.kicks-ass.net> <20220509073003.GB40730@shbuild999.sh.intel.com> <87h75zrpmh.ffs@tglx> <20220509112235.GD40730@shbuild999.sh.intel.com> Date: Mon, 09 May 2022 15:03:25 +0200 Message-ID: <87levarh7m.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Feng, On Mon, May 09 2022 at 19:22, Feng Tang wrote: > On Mon, May 09, 2022 at 12:01:42PM +0200, Thomas Gleixner wrote: >> > This option is more like a way to double-check the correctness of >> > tsc-freq got from MSR/CPUID(0x15). >> >> If at all it's a workaround for the inability and ignorance of firmware >> people. The crystal frequency and the TSC/crystal ratio _are_ known to >> the system designer and firmware people. It's really not asked too much >> to put the correct values into CPUID(0x15) and have proper quality >> control to ensure the correctness. >> >> The whole argument about early firmware and pre-production hardware is >> bogus. It's 2022 and we are debating this problem for more than a decade >> now and still hardware and firmware people think they can do what they >> want and it all can be "fixed" in software. It's not rocket science to >> get this straight. > > I completely understand it, as we've also suffered a lot from such > problems. This patch doesn't change any current work flow, and it simply > calibrates and prints out the freq info (warn if there is big deviation). > It acctually provides SW guys a quick way to argue with HW/FW people: > "See! You've given us a wrong number, please fix it", otherwise I heard > there was customer long ago who used atomic clock to prove the > deviation. Then please say clearly in the changelog what this is about. "Currently when HW provides the tsc freq info through MSR or CPUID(0x15), the info will be taken as the 'best guess', and kernel will set the X86_FEATURE_TSC_KNOWN_FREQ flag and skip the HW timer based recalibration, which works pretty well. And there is still very few corner case that the freq info is not accurate enough will small deviation from the actual value, like on a product with early version (fix needed) of firmware or some pre-production hardware. Add..." versus: "The kernel assumes that the TSC frequency which is provided by the hardware / firmware via MSRs or CPUID(0x15) is correct after applying a few basic consistency checks. This disables the TSC recalibration against HPET or PM timer. As a result there is no mechanism to validate that frequency in cases where a firmware or hardware defect is suspected. Add..." Can you spot the difference in intention? The first one sounds like: We need to tolerate the hardware/firmware induced crap. The second one says: Provide a mechanism to validate because we cannot trust hardware / firmware. Hmm? >> Aside of that HPET has become unrealiable and PM timer is not guaranteed >> to be there either. So we really do not need a mechanism to enforce >> recalibration against something which is not guaranteed to provide >> sensible information. > > Correct. The HPET on new client platforms turn to be disabled for the > PC10 issue, though it's fine on server platforms where tsc accuracy is > more important. TSC accuracy is important in any case. Why would it be more important on server platforms? Just because? > Also even for the disabled HPET case, I remembered that you've once > suggested to leverage its capability for calibration, and only disable > it before cpu idle framework really starts :) Correct, but that would only be valid for early boot calibration and not accross the recalibration. That's why we ended up disabling HPET early in case of PC10. See hpet_is_pc10_damaged(). Thanks, tglx