Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4221270imm; Mon, 30 Jul 2018 10:39:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdAlfA9moDhS6xRJzp2932l2hTjXymThcerSkQf2t1y/ZZ9MPLKHmszQLXqyLaXzigpW4Ke X-Received: by 2002:a62:bd4:: with SMTP id 81-v6mr18875120pfl.67.1532972368520; Mon, 30 Jul 2018 10:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532972368; cv=none; d=google.com; s=arc-20160816; b=xHAmPWRN4j74aP87WaVGI4QTB+WCOMPr+eE1E8cCFfK+wZ49SlnISllhR9gyCIT946 MduXJuztuSUz5RnO/j0yJvkrxBVMKdYyDK1sfJRMvOvR2nrQ16Wp09aA3oCtym07DT/j 6lV28tSEVR2qoIBETYHTLb+V9Boyw4BDzOEi1AP92rm4sM4ky2bwBR1zBhMMHl6u/p6K HT9FTtWWIHL5dSjs/YcQDxyEwI/u/+fX/cu7H4kPlPNtDVmTJlfTUtkV8A2LrkYCqTqR 0ZdBi7wLmpJQBC9B+BwQSwbwtrUteJXilvyOu2GNz4QsahiCkBt9aWqAEDDbTX+LqlRp kFfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=Po+NbxETW6VYjblAnwRDkNTp1TQlzZaIWRBzawMTI8U=; b=fbbxPtx1QwYjf5hkejrBN2nCR/nAU7x9yzR0JZsAOr+pvJG2PlH2YIVsXinP18n/l0 QpUxM1joGbWyGosaUdbj893jQY1Cx9ikg4ZnsmV44MVU67ju7WlM832ZVZPWcQYRjlcU 1JwpMkl2bTA7+mpHTdNNUSrGL8NDdn/QRkzeWRwIDXcmJ8hrRcmWmgtDZTUJU6Hh3HEm X4+yshwV/7Tg6qF5ydgYmknDdBfcHLKPaLmE/evztDashT6z4oxTVk4Q2q5yP7R2DVAc m6r7epe1fCE8jiJQoYNkiHyiYMPYLkSQLISjT+Qa/ymD/7j9vp+I/TouPaogAE3J/XME TkRQ== 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 e3-v6si11055950pgc.85.2018.07.30.10.39.14; Mon, 30 Jul 2018 10:39:28 -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 S1731549AbeG3TOW (ORCPT + 99 others); Mon, 30 Jul 2018 15:14:22 -0400 Received: from terminus.zytor.com ([198.137.202.136]:57417 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726888AbeG3TOW (ORCPT ); Mon, 30 Jul 2018 15:14:22 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6UHbttu2388567 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 30 Jul 2018 10:37:55 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6UHbtwl2388564; Mon, 30 Jul 2018 10:37:55 -0700 Date: Mon, 30 Jul 2018 10:37:55 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Dou Liyang Message-ID: Cc: tglx@linutronix.de, peterz@infradead.org, hpa@zytor.com, mingo@kernel.org, pasha.tatashin@oracle.com, linux-kernel@vger.kernel.org, douly.fnst@cn.fujitsu.com Reply-To: linux-kernel@vger.kernel.org, pasha.tatashin@oracle.com, douly.fnst@cn.fujitsu.com, mingo@kernel.org, tglx@linutronix.de, peterz@infradead.org, hpa@zytor.com In-Reply-To: <20180730075421.22830-2-douly.fnst@cn.fujitsu.com> References: <20180730075421.22830-2-douly.fnst@cn.fujitsu.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/timers] x86/tsc: Consolidate init code Git-Commit-ID: 608008a45798fe9e2aee04f99b5270ea57c1376f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_24_48 autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 608008a45798fe9e2aee04f99b5270ea57c1376f Gitweb: https://git.kernel.org/tip/608008a45798fe9e2aee04f99b5270ea57c1376f Author: Dou Liyang AuthorDate: Mon, 30 Jul 2018 15:54:20 +0800 Committer: Thomas Gleixner CommitDate: Mon, 30 Jul 2018 19:33:35 +0200 x86/tsc: Consolidate init code Split out suplicated code from tsc_early_init() and tsc_init() into a common helper and fixup some comment typos. [ tglx: Massaged changelog and renamed function ] Signed-off-by: Dou Liyang Signed-off-by: Thomas Gleixner Reviewed-by: Pavel Tatashin Cc: Cc: Peter Zijlstra Cc: "H. Peter Anvin" Link: https://lkml.kernel.org/r/20180730075421.22830-2-douly.fnst@cn.fujitsu.com --- arch/x86/kernel/tsc.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 02e416b87ac1..1463468ba9a0 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -182,7 +182,7 @@ static void __init cyc2ns_init_boot_cpu(void) } /* - * Secondary CPUs do not run through cyc2ns_init(), so set up + * Secondary CPUs do not run through tsc_init(), so set up * all the scale factors for all CPUs, assuming the same * speed as the bootup CPU. (cpufreq notifiers will fix this * up if their speed diverges) @@ -1389,7 +1389,7 @@ static bool __init determine_cpu_tsc_frequencies(bool early) } /* - * Trust non-zero tsc_khz as authorative, + * Trust non-zero tsc_khz as authoritative, * and use it to sanity check cpu_khz, * which will be off if system timer is off. */ @@ -1421,6 +1421,14 @@ static unsigned long __init get_loops_per_jiffy(void) return lpj; } +static void __init tsc_enable_sched_clock(void) +{ + /* Sanitize TSC ADJUST before cyc2ns gets initialized */ + tsc_store_and_check_tsc_adjust(true); + cyc2ns_init_boot_cpu(); + static_branch_enable(&__use_tsc); +} + void __init tsc_early_init(void) { if (!boot_cpu_has(X86_FEATURE_TSC)) @@ -1429,10 +1437,7 @@ void __init tsc_early_init(void) return; loops_per_jiffy = get_loops_per_jiffy(); - /* Sanitize TSC ADJUST before cyc2ns gets initialized */ - tsc_store_and_check_tsc_adjust(true); - cyc2ns_init_boot_cpu(); - static_branch_enable(&__use_tsc); + tsc_enable_sched_clock(); } void __init tsc_init(void) @@ -1456,13 +1461,10 @@ void __init tsc_init(void) setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER); return; } - /* Sanitize TSC ADJUST before cyc2ns gets initialized */ - tsc_store_and_check_tsc_adjust(true); - cyc2ns_init_boot_cpu(); + tsc_enable_sched_clock(); } cyc2ns_init_secondary_cpus(); - static_branch_enable(&__use_tsc); if (!no_sched_irq_time) enable_sched_clock_irqtime();