Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4031217ybl; Mon, 12 Aug 2019 10:12:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNuWc8D7ahArGmRqBn/4R9uifUDpkR6SQ5l27Me4URFA1pNacsIx2YGdV8gQqKbKFMQjsS X-Received: by 2002:a17:902:d90a:: with SMTP id c10mr32880364plz.208.1565629956439; Mon, 12 Aug 2019 10:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565629956; cv=none; d=google.com; s=arc-20160816; b=Hu2l9TY4QESUKfaIP5C0PEZ6H/IdBYjXGOpBXz5AKtLpA8qGqqV70jCo1+xff5t7G4 0i04Rqs2DHobf+jIBPUGqzdJqbwsvOzGlZlZXrSCKT/Hq/0CfNWw2EhavljCfQs+8QmW HErChcpd5xYrB/POOgRK9YMJ8GSOwbY2YGULMX4IdOhnccacef1Cj4faIonLmUHqHcjH iQcyRZF/0SXot/o2FDWCR3k1eTUCeBXe7TIAx3zmeRYivpgpVG/Nuwwu7gB7/RDgz7Yu z+NVyrIu4Z3w4Ov2VGRyvCRTP1s0gKRA8XLBE262VluGCxT7Vsu2+PvPjzA6Qlf5Zuij JGrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=jwwC/fm+jTQNtLHcg+aPzV9sg8bdPk+pxJRX0W6SvLY=; b=FMGnaonN9pjxziY8m6IMAJkzItHalzQLWaEtmNRSrvC6k2vi+h0l9nrc75ul63+g8r lxUiWoFh2NF2IGLasrMB//zX9IpcNqnaU55wn0SD+Wm9zhOBUMrem+LULvf8PajQ8MoD d+yo3/OHuchy0snZP8iQKuoJHxsT+GjQFF1zeq50VIKGF0GGMAqs2d1sGNCaVwzAHCC3 MZUO4Aq7U7LtdG2wBcKu89ulEHZIoG0tT14oKacy6xl2YlfNP4iMGNsmu6VM8onZuGJg K2Ti4HjYjwYazwOLIDLuQJhwThbO5TZp0GJjnRArfuNYxXJRCghrrUeY5SUreM51LUA8 zRQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n187si62317870pgn.362.2019.08.12.10.12.20; Mon, 12 Aug 2019 10:12:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726993AbfHLRLg (ORCPT + 99 others); Mon, 12 Aug 2019 13:11:36 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:60419 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726263AbfHLRLg (ORCPT ); Mon, 12 Aug 2019 13:11:36 -0400 Received: from p200300ddd71876867e7a91fffec98e25.dip0.t-ipconnect.de ([2003:dd:d718:7686:7e7a:91ff:fec9:8e25]) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hxDqv-0001sg-ND; Mon, 12 Aug 2019 19:11:25 +0200 Date: Mon, 12 Aug 2019 19:11:20 +0200 (CEST) From: Thomas Gleixner To: Aubrey Li cc: "Li, Aubrey" , "Lendacky, Thomas" , Daniel Drake , "x86@kernel.org" , "H . Peter Anvin" , Linux Kernel , Endless Linux Upstreaming Team , Jiri Slaby Subject: Re: [PATCH] x86/apic: Handle missing global clockevent gracefully In-Reply-To: Message-ID: References: <81666b28-d029-56c3-8978-90abc219d1b7@linux.intel.com> <3d14b0cc-3cca-1874-3521-4ee2ec52141d@amd.com> <5bf28ba4-b7c1-51de-88ae-feebae2a28db@amd.com> <75e59ac6-5165-bd0a-aec9-be16d662ece9@amd.com> <1803ad97-74f4-28c6-58c8-c52b3d1e5b1f@linux.intel.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 12 Aug 2019, Aubrey Li wrote: > On Mon, Aug 12, 2019 at 8:25 PM Thomas Gleixner wrote: > > > > On Mon, 12 Aug 2019, Li, Aubrey wrote: > > > On 2019/8/9 20:54, Thomas Gleixner wrote: > > > > + local_irq_disable(); > > > > /* > > > > * Setup the APIC counter to maximum. There is no way the lapic > > > > * can underflow in the 100ms detection time frame > > > > */ > > > > __setup_APIC_LVTT(0xffffffff, 0, 0); > > > > > > > > - /* Let the interrupts run */ > > > > - local_irq_enable(); > > > > + /* > > > > + * Methods to terminate the calibration loop: > > > > + * 1) Global clockevent if available (jiffies) > > > > + * 2) TSC if available and frequency is known > > > > + */ > > > > + jif_start = READ_ONCE(jiffies); > > > > + > > > > + if (tsc_khz) { > > > > + tsc_start = rdtsc(); > > > > + tsc_perj = div_u64((u64)tsc_khz * 1000, HZ); > > > > + } > > > > + > > > > + while (lapic_cal_loops <= LAPIC_CAL_LOOPS) { > > > > > > Is this loop still meaningful, can we just invoke the handler twice > > > before and after the tick? > > > > And that solves what? > > > I meant, can we do this one time? > - lapic_cal_t1 = read APIC counter > - /* Wait for a tick to elapse */ > - lapic_cal_t2 = read APIC counter Sure, but how does this work with randomly broken hardware, e.g. PIT running at the wrong frequency/ The calibration code is trying to verify against as many and as reliable references and it served us well so far. > I'm not clear why we still need this loop, to use the > existing lapic_cal_handler()? A single tick is way too small to get a proper calibration. Sure, this can be optimized by avoiding the loop and have a longer delay, but you definitely want to use the rest of the calibration code as is. Aside of that this was the minial fix I came up with which might be suitable for backporting. These platforms seem to come out of the woods right now, so we definitely want support for them in LTS kernels as well. Thanks, tglx