Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2213996imm; Thu, 19 Jul 2018 15:34:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcILaQqvKlr1TuxBjn9W4rhQRQfhcru2gWBoSgx/QG31+yySyADiMDiw2B2w5/aPAKv+yXc X-Received: by 2002:a62:cd3:: with SMTP id 80-v6mr11411107pfm.184.1532039687491; Thu, 19 Jul 2018 15:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532039687; cv=none; d=google.com; s=arc-20160816; b=gjErjeReW9LJwoZ5Xfjx/6V2TeBarK8T3EH25YWCZL7ybKUemlP1sPwt8Hs1+0i9he D51IgXslNwDpGXLOinA7Ax3l6u7mi3c0KWFBkPiWPM6TePZZ5T5gXVyvVSDiC/Geh4Fs A4Y8I0a0+geF9Ecy99iDbCkXI7bxhnPGep4mZPInkeV5tQG5gsvt3+jQOiDIAHw/MX+N w43+vPwVczXjVJs2fsJzpnc2/65cgxuiHPT2ogtpqUFJPKSaF0CN1W3k/qYMiZDV/AO/ TyOOd7Q0WiX6SoQyR5sWdQXFtkrKAsFT0WjWZt8iB5LO/QDg6nyKNK2XmlfNCWmrS69K FfgQ== 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=GWumEh5M5fqFcQjYKdk+sRzkBVG1pmErJs9wTCxPWZQ=; b=lce1eDc2vltHedOBWsJ7801dJOVx/DsnFMtODFWkmqkhH6tr5aD+S7KyICHFcyFSWX 3PXY98w0Kgrzhlii7tNYcQqmzOVCZzHRmRjXU64YlVB0kxd3EiDS/6hSSKR1CEKx8tUS 0C79AyxWxQydqbB+abOD8O/MG3+GLtFb6rwHtIWGT1DL7OBuuNr21JgmFrd0LzqUfNxZ NBYVNntQND7X2aIacey/dw6L6UEFp/x+DDOpSVwTU2jgJklNVQkS0wsVWd3LqjWUE/AQ /00gCvz5vznjQSAIdaMPP4pAgZplSO0lC41rDiXXpaLK4girPLz1FWBjtzBLp/xYNWBQ +8qQ== 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 1-v6si272365plx.227.2018.07.19.15.34.32; Thu, 19 Jul 2018 15:34:47 -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 S1731267AbeGSXST (ORCPT + 99 others); Thu, 19 Jul 2018 19:18:19 -0400 Received: from terminus.zytor.com ([198.137.202.136]:45533 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730315AbeGSXST (ORCPT ); Thu, 19 Jul 2018 19:18:19 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6JMWmiY2439652 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 19 Jul 2018 15:32:48 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6JMWlVA2439649; Thu, 19 Jul 2018 15:32:47 -0700 Date: Thu, 19 Jul 2018 15:32:47 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Pavel Tatashin Message-ID: Cc: tglx@linutronix.de, hpa@zytor.com, linux-kernel@vger.kernel.org, pasha.tatashin@oracle.com, peterz@infradead.org, mingo@kernel.org Reply-To: pasha.tatashin@oracle.com, tglx@linutronix.de, hpa@zytor.com, linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@kernel.org In-Reply-To: <20180719205545.16512-23-pasha.tatashin@oracle.com> References: <20180719205545.16512-23-pasha.tatashin@oracle.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/timers] sched/clock: Move sched clock initialization and merge with generic clock Git-Commit-ID: 5d2a4e91a541cb04d20d11602f0f9340291322ac 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=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q autolearn=ham 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: 5d2a4e91a541cb04d20d11602f0f9340291322ac Gitweb: https://git.kernel.org/tip/5d2a4e91a541cb04d20d11602f0f9340291322ac Author: Pavel Tatashin AuthorDate: Thu, 19 Jul 2018 16:55:41 -0400 Committer: Thomas Gleixner CommitDate: Fri, 20 Jul 2018 00:02:43 +0200 sched/clock: Move sched clock initialization and merge with generic clock sched_clock_postinit() initializes a generic clock on systems where no other clock is provided. This function may be called only after timekeeping_init(). Rename sched_clock_postinit to generic_clock_inti() and call it from sched_clock_init(). Move the call for sched_clock_init() until after time_init(). Suggested-by: Peter Zijlstra Signed-off-by: Pavel Tatashin Signed-off-by: Thomas Gleixner Cc: steven.sistare@oracle.com Cc: daniel.m.jordan@oracle.com Cc: linux@armlinux.org.uk Cc: schwidefsky@de.ibm.com Cc: heiko.carstens@de.ibm.com Cc: john.stultz@linaro.org Cc: sboyd@codeaurora.org Cc: hpa@zytor.com Cc: douly.fnst@cn.fujitsu.com Cc: prarit@redhat.com Cc: feng.tang@intel.com Cc: pmladek@suse.com Cc: gnomes@lxorguk.ukuu.org.uk Cc: linux-s390@vger.kernel.org Cc: boris.ostrovsky@oracle.com Cc: jgross@suse.com Cc: pbonzini@redhat.com Link: https://lkml.kernel.org/r/20180719205545.16512-23-pasha.tatashin@oracle.com --- include/linux/sched_clock.h | 5 ++--- init/main.c | 4 ++-- kernel/sched/clock.c | 27 +++++++++++++++++---------- kernel/sched/core.c | 1 - kernel/time/sched_clock.c | 2 +- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/include/linux/sched_clock.h b/include/linux/sched_clock.h index 411b52e424e1..abe28d5cb3f4 100644 --- a/include/linux/sched_clock.h +++ b/include/linux/sched_clock.h @@ -9,17 +9,16 @@ #define LINUX_SCHED_CLOCK #ifdef CONFIG_GENERIC_SCHED_CLOCK -extern void sched_clock_postinit(void); +extern void generic_sched_clock_init(void); extern void sched_clock_register(u64 (*read)(void), int bits, unsigned long rate); #else -static inline void sched_clock_postinit(void) { } +static inline void generic_sched_clock_init(void) { } static inline void sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) { - ; } #endif diff --git a/init/main.c b/init/main.c index 3b4ada11ed52..162d931c9511 100644 --- a/init/main.c +++ b/init/main.c @@ -79,7 +79,7 @@ #include #include #include -#include +#include #include #include #include @@ -642,7 +642,7 @@ asmlinkage __visible void __init start_kernel(void) softirq_init(); timekeeping_init(); time_init(); - sched_clock_postinit(); + sched_clock_init(); printk_safe_init(); perf_event_init(); profile_init(); diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c index 10c83e73837a..0e9dbb2d9aea 100644 --- a/kernel/sched/clock.c +++ b/kernel/sched/clock.c @@ -53,6 +53,7 @@ * */ #include "sched.h" +#include /* * Scheduler clock - returns current time in nanosec units. @@ -68,11 +69,6 @@ EXPORT_SYMBOL_GPL(sched_clock); __read_mostly int sched_clock_running; -void sched_clock_init(void) -{ - sched_clock_running = 1; -} - #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK /* * We must start with !__sched_clock_stable because the unstable -> stable @@ -199,6 +195,15 @@ void clear_sched_clock_stable(void) __clear_sched_clock_stable(); } +static void __sched_clock_gtod_offset(void) +{ + __gtod_offset = (sched_clock() + __sched_clock_offset) - ktime_get_ns(); +} + +void __init sched_clock_init(void) +{ + sched_clock_running = 1; +} /* * We run this as late_initcall() such that it runs after all built-in drivers, * notably: acpi_processor and intel_idle, which can mark the TSC as unstable. @@ -385,8 +390,6 @@ void sched_clock_tick(void) void sched_clock_tick_stable(void) { - u64 gtod, clock; - if (!sched_clock_stable()) return; @@ -398,9 +401,7 @@ void sched_clock_tick_stable(void) * TSC to be unstable, any computation will be computing crap. */ local_irq_disable(); - gtod = ktime_get_ns(); - clock = sched_clock(); - __gtod_offset = (clock + __sched_clock_offset) - gtod; + __sched_clock_gtod_offset(); local_irq_enable(); } @@ -434,6 +435,12 @@ EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event); #else /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */ +void __init sched_clock_init(void) +{ + sched_clock_running = 1; + generic_sched_clock_init(); +} + u64 sched_clock_cpu(int cpu) { if (unlikely(!sched_clock_running)) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index fe365c9a08e9..552406e9713b 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5954,7 +5954,6 @@ void __init sched_init(void) int i, j; unsigned long alloc_size = 0, ptr; - sched_clock_init(); wait_bit_init(); #ifdef CONFIG_FAIR_GROUP_SCHED diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index 2d8f05aad442..cbc72c2c1fca 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -237,7 +237,7 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) pr_debug("Registered %pF as sched_clock source\n", read); } -void __init sched_clock_postinit(void) +void __init generic_sched_clock_init(void) { /* * If no sched_clock() function has been provided at that point,