Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2267774ima; Thu, 25 Oct 2018 12:14:10 -0700 (PDT) X-Google-Smtp-Source: AJdET5eF4GX7mQHTvA070qt8MmiRAw9i5pI6RCnqVceC/1kKhrQELExcCGhyvMZYVZLMDINW4IOZ X-Received: by 2002:a17:902:24e7:: with SMTP id l36-v6mr428218plg.234.1540494850900; Thu, 25 Oct 2018 12:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540494850; cv=none; d=google.com; s=arc-20160816; b=lCABktN3kw3ce+BzjpptktNEnfC0GodRda8nUx7tj1uogpwwEmesmFOe8tjh1eJtBO ni5/L3MqrHal3ryCMWKUAvUbMLOwFrb7/5q16TU06UIYRyRgDqJCYy1kLf/T36DDrl3j vWLFk8FhMTzJktt6l+J0HV7j/+LLjIYTx2A6p0awgN2+4SRb0ECgnial76C/yPiOsJ3x evg/yAyUd0tbd2/NuIXaSYBEtH+6cN+5481H+QVAKz9TRHm9PjJD5SN3Hmg1Ziv92t27 WctNCAVdrAMIINMftQiGti+oFWxZ56KRiq7Tpwsc7VQYFi8AjY0jvhCRZGpRTN8Rs9ht uJcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=7IoyRNoh8Ip6rj+cIK7KeS3pk5TzecPmeQmC2xzliVU=; b=Uez1WmnFOapKZjelLNYkHttTWT/b8mx8FOpxWA/fiaeGKalhwXP30d2Lan+aY7pBNq UeDx9MhEHlyV/n2nwQWyfO+nhz3uELVZ1zoAa2nmCB3u3bvIwBiWyxXi2m/KCQweYvD9 LRWA3GbNfYLipBMaX/m/a2rTB6r+1rF6HZDIpFhy6vvvn+IFp2fjmaEz9H16OFegG93X RYC/MpW5PMNjKaOtLnItWckMYeWXfmToJf5K9WlmJDAB9g92TJjIovKTGmYlPRxpTabD FLzZTQvPwYy9I+0B/rvR/Ke993kwb48C3NwgTR95URIVhZM5Cg1fnaNtPOsgjFig1sYO aebQ== 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 u34-v6si9080566pgk.124.2018.10.25.12.13.54; Thu, 25 Oct 2018 12:14:10 -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 S1727372AbeJZDre (ORCPT + 99 others); Thu, 25 Oct 2018 23:47:34 -0400 Received: from mga.supermicro.com ([207.212.57.84]:49172 "EHLO MGA.supermicro.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726580AbeJZDre (ORCPT ); Thu, 25 Oct 2018 23:47:34 -0400 Received: from pps.filterd (MGA.supermicro.com [127.0.0.1]) by MGA.supermicro.com (8.16.0.22/8.16.0.22) with SMTP id w9PJBRc0028148; Thu, 25 Oct 2018 12:13:27 -0700 Received: from ex2013-mbx2.supermicro.com (Ex2013-MBX2.supermicro.com [10.2.1.38]) by MGA.supermicro.com with ESMTP id 2n83ysd3gj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 25 Oct 2018 12:13:27 -0700 Received: from [172.16.95.100] (10.2.0.41) by Ex2013-MBX2.supermicro.com (10.2.1.38) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Thu, 25 Oct 2018 12:13:26 -0700 Subject: Re: [RFC] x86, tsc: Add kcmdline args for skipping tsc calibration sequences To: Prarit Bhargava , "Brown, Len" , "linux-kernel@vger.kernel.org" CC: "mingo@kernel.org" , "Du, Alek" , "arjan@linux.intel.com" , "Tang, Feng" References: <1A7043D5F58CCB44A599DFD55ED4C94849A1AACF@FMSMSX126.amr.corp.intel.com> <94bebaa1-992b-572b-0d24-e08037611358@supermicro.com> <70cdf321-cef7-aa26-1ca8-33378b3afdd9@supermicro.com> <18d873f6-a911-200b-7bc7-8f4b4f3c5161@supermicro.com> <6e40fea8-9b42-3785-7d4d-36f120980d66@redhat.com> From: patrickg Message-ID: Date: Thu, 25 Oct 2018 12:13:26 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <6e40fea8-9b42-3785-7d4d-36f120980d66@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.2.0.41] X-ClientProxiedBy: EX2013-CA1.supermicro.com (10.2.1.31) To Ex2013-MBX2.supermicro.com (10.2.1.38) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-25_10:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry for the delay; lkml folder sorting gone wrong. On 10/25/18 11:01 AM, Prarit Bhargava wrote: > Patrick can you reply back with the entire patch Yes; watch the editor bork it even more than it originally did, though. ---Copypasta of first RFC patch--- --- diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 74392d9..5a07d12 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -47,6 +47,13 @@ static DEFINE_STATIC_KEY_FALSE(__use_tsc); int tsc_clocksource_reliable; +/* + * TSC calibration sequence disablement + */ +int calibrate_cpuid_khz_disabled = 0; +int calibrate_msr_disabled = 0; +int calibrate_quick_disabled = 0; + static u32 art_to_tsc_numerator; static u32 art_to_tsc_denominator; static u64 art_to_tsc_offset; @@ -281,6 +288,32 @@ static int __init tsc_setup(char *str) __setup("tsc=", tsc_setup); +static int __init setup_tsc_calibration_order(char *str) +{ + if (!str) + return -EINVAL; + + while (*str) { + if (!strncmp(str, "nocpuid", 7)) { + calibrate_cpuid_khz_disabled = 1; + pr_info("TSC CPUID khz calibrate disabled\n"); + } else if (!strncmp(str, "nomsr", 5)) { + calibrate_msr_disabled = 1; + pr_info("TSC msr calibrate disabled\n"); + } else if (!strncmp(str, "noquick", 7)) { + calibrate_quick_disabled = 1; + pr_info("TSC quick calibrate disabled\n"); + } + + str += strcspn(str, ","); + while (*str == ',') + str++; + } + return 1; +} + +__setup("tsc_calibrate=", setup_tsc_calibration_order); + #define MAX_RETRIES 5 #define SMI_TRESHOLD 50000 @@ -675,19 +708,25 @@ unsigned long native_calibrate_cpu(void) unsigned long flags, latch, ms, fast_calibrate; int hpet = is_hpet_enabled(), i, loopmin; - fast_calibrate = cpu_khz_from_cpuid(); - if (fast_calibrate) - return fast_calibrate; + if (!calibrate_cpuid_khz_disabled) { + fast_calibrate = cpu_khz_from_cpuid(); + if (fast_calibrate) + return fast_calibrate; + } - fast_calibrate = cpu_khz_from_msr(); - if (fast_calibrate) - return fast_calibrate; + if (!calibrate_msr_disabled) { + fast_calibrate = cpu_khz_from_msr(); + if (fast_calibrate) + return fast_calibrate; + } - local_irq_save(flags); - fast_calibrate = quick_pit_calibrate(); - local_irq_restore(flags); - if (fast_calibrate) - return fast_calibrate; + if (!calibrate_quick_disabled) { + local_irq_save(flags); + fast_calibrate = quick_pit_calibrate(); + local_irq_restore(flags); + if (fast_calibrate) + return fast_calibrate; + } /* * Run 5 calibration loops to get the lowest frequency value ---