Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp9282imm; Tue, 17 Jul 2018 19:26:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfkbkz6nuGC9p6vlfhLqh6MYy7iDoI+3IxtB3BBj+TpwSbpY0tyYwO6+8XOC+9NO8YWyDKQ X-Received: by 2002:a63:c608:: with SMTP id w8-v6mr3874659pgg.16.1531880813327; Tue, 17 Jul 2018 19:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531880813; cv=none; d=google.com; s=arc-20160816; b=BQ4qWal4Kixc9e3PLrZQ296HT2hJR4muVw71RdCGv2KW7/QP4SC+MMN84xrp3YDlXf +25WhEpSIeaq1idOTbXXKTknjaLON2I92RIv3MStXnsvZ0C6CjMR8Wa0cBq/Tyd1+Ndw W/N16EIhJvK+6drph/STIAf5u3Tl5WYkEYTA7Ag9gpw9olrJrmrDWyIIij0FxRSuh42w /jKH50DTsCvdgPlO5yj+VkJ1zBsxqdlFfHO5xDahLuEzVV2mATaUIEstgeSvbdTmML5h FN3mRXFzDr/7Rt/Ubuj5/A6k+oIu17v8C7CI+MdvZfuyXQ9AyCAQDsp41QgyzKHVbw3L jDzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:arc-authentication-results; bh=wP1EAwPBudwlpkgBbz/HfISvhtkakFKuwq1hfZ/WEPo=; b=gwxP0lgDq0OqYU7CyEaXGrk8JURUfyBreIQLH1Fadz+dVWCSoc/uIz5x4XUskO54dX xKsrGydFEzf62AFlZ6tJr6KTAv/QxrlYbseTNUHk46VjQv8FuTYfi82gZv6sPnJSX2tT EKx7FuEd/xt480X93CQ2M9Q/Gq90AzQ5FLAXobquFtPExsn16SmqAZSmXfL4szY2BH6o CEGjN1wHX/2G+Q5B0z+PaAN5PxyFAZu9/vioofkQO83DQCFwi1Joq73mYpUCWyAhk4Kc C4ZTM9MMfpknz2jBZdaEx1rfnSEN6xvE7RFdp35TTBG/9u9NE5MLgWoSxZSztSAXSflC m8JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=x4QbQ19e; 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=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v129-v6si2413055pfv.278.2018.07.17.19.26.38; Tue, 17 Jul 2018 19:26:53 -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=@oracle.com header.s=corp-2018-07-02 header.b=x4QbQ19e; 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=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732060AbeGRDBA (ORCPT + 99 others); Tue, 17 Jul 2018 23:01:00 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:45048 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731800AbeGRC7k (ORCPT ); Tue, 17 Jul 2018 22:59:40 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w6I2LgEI002259; Wed, 18 Jul 2018 02:23:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=wP1EAwPBudwlpkgBbz/HfISvhtkakFKuwq1hfZ/WEPo=; b=x4QbQ19eao0qvs4J70KPDz2U7Xnx9wXXXX5LaWILgkNtSWTAhc5F0oNPbdnH4Vzy/DeK ZlunA5cBvzNFOydomZuLbt42Hdij5AHhrf2TwrLWBYYYaykPXGmtV1XrMbtaW5ckatFl NOnGXQij7SviGBb+GOwWXA5Nm+YqmJaaAMW+c44iZNmpkziFHbCrVxtWJExpNV0vRyJL 45EqWz0h8IYS6pNo9rURbSTG+7B0cIccBwFivPNyCBfYvhhk6ZPJ6u5Hw1lWH2nJcDla 6lT4CrSyySFztszgtkY+v0veByJ3gHOFwXV0TH9EhHhf+P5sUjOQMeyeWhOedHthyl+B lQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2k7a3t34dv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jul 2018 02:23:18 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w6I2NI0R029182 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jul 2018 02:23:18 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w6I2NH02017708; Wed, 18 Jul 2018 02:23:17 GMT Received: from localhost.localdomain (/73.69.118.222) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 17 Jul 2018 19:23:16 -0700 From: Pavel Tatashin To: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux@armlinux.org.uk, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, john.stultz@linaro.org, sboyd@codeaurora.org, x86@kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, tglx@linutronix.de, hpa@zytor.com, douly.fnst@cn.fujitsu.com, peterz@infradead.org, prarit@redhat.com, feng.tang@intel.com, pmladek@suse.com, gnomes@lxorguk.ukuu.org.uk, linux-s390@vger.kernel.org, pasha.tatashin@oracle.com, boris.ostrovsky@oracle.com, jgross@suse.com, pbonzini@redhat.com Subject: [PATCH v14 23/25] sched: move sched clock initialization and merge with generic clock Date: Tue, 17 Jul 2018 22:22:09 -0400 Message-Id: <20180718022211.6259-24-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180718022211.6259-1-pasha.tatashin@oracle.com> References: <20180718022211.6259-1-pasha.tatashin@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8957 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807180026 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sched_clock_postinit() initializes a generic clock on systems where no other clock is porvided. 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 --- 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, -- 2.18.0