Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3756812ybl; Mon, 12 Aug 2019 06:00:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJ8DorL1687Hfnw5HwkEDCBdMUYa5f8IEVPiyCg9+5jj7/7CiSgJr/uMU0BO9M/zLfRKPr X-Received: by 2002:a62:be02:: with SMTP id l2mr36290708pff.63.1565614856797; Mon, 12 Aug 2019 06:00:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565614856; cv=none; d=google.com; s=arc-20160816; b=CvsJvpKH9Rx5tGCN6/zAG0+4sL0ylwqnccRYHZo5Z8DzMpv0qJe1UkH/3ZasrdVIfF 5zujy3dDjM46l2kaKwOB7U4V6UQYQUlIL0S9FAfyZg05nw49nhPteZ5hsummcBulChnZ PJ5lTvS9GGbs2b3QYQNZaBq3nG2eJ8qWcEo5HnzWrE884wFhn2fUGcVoXxvfjm1eLqAL U07duoOmsTBdUcYWYSR/TaSdMnuzVDTGN783j0AkrF+gVl0JhBaPXsOJIj/oeKSlohbM M9sdg3V+hVdSu7UxO2r8GMAiEj5ZYp05OrTh6qiV7y97byvusNsVd3p+pXGX+H74Wyjz X+qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=F2Nq/zcAHmKnyWJZUFugKDFlDxB+1xeCPHyjsiZ4S/U=; b=nlJN0Cc/GdPLF0PGoAtU5wpX5WmoHQ2OIru7bQqNq8wRAF5IsHWo6snZfPNOycueTb olcNW0ueMov06OpsJn+W/9opiluI9Xddish3f7cmzWcWWAk8qF4MyWHpWWlSPMC45cUM xxB4BthD9Msoy7jrADJrR8NCNHQvornKFFON0kE7o2U3195n3mG0L+73CfmoajfvXOq3 byu+O972PR7tEV77MogfdAecL3LiP0tuwlm+Okw3Mnr5fyjAHPQXeMoeHvkbsE4ONmLP SU71l+deQyOhN2DIIQ0zjgLasgVZNm+mCgjpawfsPQSO3gGLMWII/M6fVqrKLKwDvaOB Skyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ox3zecLL; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n18si58033109plp.215.2019.08.12.06.00.41; Mon, 12 Aug 2019 06:00:56 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ox3zecLL; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728552AbfHLM7z (ORCPT + 99 others); Mon, 12 Aug 2019 08:59:55 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:44458 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbfHLM7z (ORCPT ); Mon, 12 Aug 2019 08:59:55 -0400 Received: by mail-lj1-f193.google.com with SMTP id e24so1504856ljg.11 for ; Mon, 12 Aug 2019 05:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F2Nq/zcAHmKnyWJZUFugKDFlDxB+1xeCPHyjsiZ4S/U=; b=Ox3zecLLBuTUitWMEKguTdU+91neVQRMhUjF6XXwufTANvpF5wwbvg6lM78G+Xci5J G1tchLUxkpKCj/Y26M92mAcJRJSu9KaiN6smELAF0Q2nUpe6XEUap8WZ//TMKWUR5DwT +cw4rg1DGLeah4TpC2+nEkyq+6Lc9hakaFV2uI45V9ZqAUP4v+f2lR7ah2r6nDBtXpUQ xfIOmb52HehnFaFM9Gs84NzOw3jrumOVjQfcQqZEbDFNgjifAG20QNgIOeP5JcEblyYv tPkUqHQ9MhstecI/OjGLmqhkAPbiLgfcSui740aqrmvu8m5+P1FZf4GVGKLUQUzJyIVM w5cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F2Nq/zcAHmKnyWJZUFugKDFlDxB+1xeCPHyjsiZ4S/U=; b=lyIb1ddV2tJYsR+Q+RQZb8W9+FwgyCmUKvFY5fyl75/FV7x9PFdx9kqhM6hnnIQptt gp5F3IzSV1HIIb+2AIInssAGuEu48e0ZdwMXkDlS0RsNXEWE2WOXoI++7Zy1buwid0fg a1ewgrOqWhTSgptfugzDWu+ydMXb8Xv0DMNxCQOmhzpjrtvxQzgyJFIpdFnlBORxjKuh PNg+eGjSyHUH+4XR5eHr2k3rbS2r1tfIloJo+LG6YNUie1jGbwcRef2e2JdPUmkaBmpw Rxqnt2+o7VsQ1W8qPNdNemb+7U5znqxhJxoVDUXx0/lfRnQ6F7vniS+brEyFuDZc93/t /n0g== X-Gm-Message-State: APjAAAVRLhJF+g/bywcG0cy2aLJGn7TI+L2uo7lyGGP7+k7k2VK+NQ4m B0vNpnz80gwdUrpDVjiGo0oBPE1Hqqc3WMBRbf4= X-Received: by 2002:a2e:9b83:: with SMTP id z3mr18122610lji.84.1565614793893; Mon, 12 Aug 2019 05:59:53 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: From: Aubrey Li Date: Mon, 12 Aug 2019 20:59:42 +0800 Message-ID: Subject: Re: [PATCH] x86/apic: Handle missing global clockevent gracefully To: Thomas Gleixner Cc: "Li, Aubrey" , "Lendacky, Thomas" , Daniel Drake , "x86@kernel.org" , "H . Peter Anvin" , Linux Kernel , Endless Linux Upstreaming Team , Jiri Slaby Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 I'm not clear why we still need this loop, to use the existing lapic_cal_handler()? Thanks, -Aubrey