Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7275107imm; Thu, 28 Jun 2018 00:34:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIo+gOREVaGyVv6t02osHZiKbV9UdpXPmy/fyDsGDlP6E4SedZLlCaM1ZkE5Wx39yHZbC7P X-Received: by 2002:a63:2d45:: with SMTP id t66-v6mr7740476pgt.381.1530171283190; Thu, 28 Jun 2018 00:34:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530171283; cv=none; d=google.com; s=arc-20160816; b=BBBIOQbMzvJjVDJsI9v6Fw8atTbj6mVVWm3YdWObHrQFeusXl56fpeqMj4Dz+0FLdM QbwAG+qUeFh9gNhkIxn1smoRtWdM07cIAGqKeG160XUEZo8rc4+/LoJIwsciZvoF84f/ /a0iou6RcMF4aI+V+gH0lA7yt4rO0e87cRvrr8rYlD4a/wjOryfKzZDGkm5xY1ndkmX6 WS+x/gjKmylmX8NoSaZL0lk/AQ6OGXRkMqiSEvziGPDDqCUqSfs/UTfF9/E8no9quFPG VpD49ZNBAMuj7YRSGW9zsjNnmbQ4O1wHIAzPtgIXULAV8mB+7EH9KV9XLfc/EDIBkzeY 3ZQw== 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 :arc-authentication-results; bh=R7nQ8RKMksw2qtDrASmZOz5/UgYTm6JLd5Z2kWIjHCQ=; b=PRerxX5EuOdHwp4gE7haAOUFOTu9XTpyS9beQzJg69KdDhsYCOeHpBPb297vDpUhSb orbAdN7JDi422pBCE0Cl4EMixfY7Y3smZFLKyt+j7fdnTc9HVQlJ5ZRbtCaqfR331QmT MJNypv5V7GKXSjRYTNMb3y1XLye74TYe2KDgi7imYpd3val8Td1IVo/tKJFRhTGdHgGL jN+WHKpNWoGXJZEFnnKMuDGcfNupxqiTVlLqF9fO3oV3LqDE55H8BVoxqr5j/rjdm6Kx yWUQ84soA3hcvxkNCBsb1igwonO11aCLnBIYkheb3+AGyY/LllZdA7dwzjSxC0rXbk1G daZw== 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 p8-v6si5765317pfh.249.2018.06.28.00.34.29; Thu, 28 Jun 2018 00:34:43 -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 S934068AbeF1Hcb (ORCPT + 99 others); Thu, 28 Jun 2018 03:32:31 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:55348 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933094AbeF1Hca (ORCPT ); Thu, 28 Jun 2018 03:32:30 -0400 Received: from hsi-kbw-5-158-153-55.hsi19.kabel-badenwuerttemberg.de ([5.158.153.55] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fYRP9-0002Pl-Ls; Thu, 28 Jun 2018 09:31:47 +0200 Date: Thu, 28 Jun 2018 09:31:41 +0200 (CEST) From: Thomas Gleixner To: Pavel Tatashin cc: Steven Sistare , Daniel Jordan , linux@armlinux.org.uk, schwidefsky@de.ibm.com, Heiko Carstens , John Stultz , sboyd@codeaurora.org, x86@kernel.org, LKML , mingo@redhat.com, hpa@zytor.com, douly.fnst@cn.fujitsu.com, peterz@infradead.org, prarit@redhat.com, feng.tang@intel.com, Petr Mladek , gnomes@lxorguk.ukuu.org.uk, linux-s390@vger.kernel.org Subject: Re: [PATCH v12 09/11] x86/tsc: prepare for early sched_clock In-Reply-To: Message-ID: References: <20180621212518.19914-1-pasha.tatashin@oracle.com> <20180621212518.19914-10-pasha.tatashin@oracle.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 Tue, 26 Jun 2018, Pavel Tatashin wrote: > On Tue, Jun 26, 2018 at 11:44 AM Thomas Gleixner wrote: > > I have an idea how to distangle it and we'll end up in a staged approach, > > which looks like this: > > > > 1) Earliest one (not sure how early yet) > > > > Attempt to use MSR/CPUID. If not running on a hypervisor this can > > try the quick PIT calibration, but nothing else. > > > > 2) Post init_hypervisor_platform() > > > > An attempt to use the hypervisor data can be made. > > > > 3) Post early_acpi_boot_init() > > > > This can do PIT/HPET based calibration > > > > 4) Post x86_dtb_init() > > > > PIT/PMTIMER based calibration > > > > Once tsc_khz is known, no further attempts of calibration are made. I'll > > look into that later tonight. > > I think, there are no reasons to try staged attempts. It usually gets > harder to maintain overtime. In my opinion it is best if do it in two > tries, as right now, but just cleaner. The first attempt we get a > crude result, using the lowest denominator to which current logic > might fallback if something else is not available that early in boot: > i.e cpu calibration loop in native_calibrate_cpu() but later get > something better. Also, even if early clock does not work because we > could not get tsc early, it is not a problem, we still will probably > determine it later during tsc_init call. I still want to document the unholy mess of what is initialized and available when. We have 5 hypervisors and 3 different points in early boot where the calibrate_* callbacks are overwritten. The XEN PV one is actually post tsc_init_early() for whatever reason. That's all completely obscure and any attempt of moving tsc_early_init() earlier than where it is now is just lottery. The other issue is that double calibration, e.g. doing the PIT thing twice is just consuming boot time for no value. All of that has been duct taped over time and we really don't want yet another thing glued to it just because we can. > I have re-wrote tsc_early_init()/tsc_init(), they are much simpler now: > > void __init tsc_early_init(void) > { > if (!boot_cpu_has(X86_FEATURE_TSC)) > return; > > if (!determine_cpu_tsc_frequncies()) > return; That still wants to do the TSC_ADJUST call here. Thanks, tglx