mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pavel Tatashin <pasha.tatashin@oracle.com>
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
Subject: [PATCH v8 4/6] sched: early boot clock
Date: Wed,  8 Nov 2017 22:01:59 -0500	[thread overview]
Message-ID: <20171109030201.5991-5-pasha.tatashin@oracle.com> (raw)
In-Reply-To: <20171109030201.5991-1-pasha.tatashin@oracle.com>

Allow sched_clock() to be used before schec_clock_init() and
sched_clock_init_late() are called. This provides us with a way to get
early boot timestamps on machines with unstable clocks.

Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
---
 kernel/sched/clock.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c
index e086babe6c61..8bc603951c2d 100644
--- a/kernel/sched/clock.c
+++ b/kernel/sched/clock.c
@@ -217,6 +217,11 @@ void clear_sched_clock_stable(void)
  */
 static int __init sched_clock_init_late(void)
 {
+	/* Transition to unstable clock from early clock */
+	local_irq_disable();
+	__gtod_offset = sched_clock() + __sched_clock_offset - ktime_get_ns();
+	local_irq_enable();
+
 	sched_clock_running = 2;
 	/*
 	 * Ensure that it is impossible to not do a static_key update.
@@ -362,8 +367,9 @@ u64 sched_clock_cpu(int cpu)
 	if (sched_clock_stable())
 		return sched_clock() + __sched_clock_offset;
 
-	if (unlikely(!sched_clock_running))
-		return 0ull;
+	/* Use early clock until sched_clock_init_late() */
+	if (unlikely(sched_clock_running < 2))
+		return sched_clock() + __sched_clock_offset;
 
 	preempt_disable_notrace();
 	scd = cpu_sdc(cpu);
-- 
2.15.0

  parent reply	other threads:[~2017-11-09  3:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-09  3:01 [PATCH v8 0/6] Early boot time stamps for x86 Pavel Tatashin
2017-11-09  3:01 ` [PATCH v8 1/6] x86/tsc: remove tsc_disabled flag Pavel Tatashin
2017-11-13  3:52   ` Dou Liyang
2017-11-13 18:51     ` Pavel Tatashin
2017-11-09  3:01 ` [PATCH v8 2/6] time: sync read_boot_clock64() with persistent clock Pavel Tatashin
2017-11-13  3:47   ` Dou Liyang
2017-11-14 19:57     ` Pavel Tatashin
2017-11-15  2:47       ` Dou Liyang
2017-11-15  3:56         ` Pavel Tatashin
2017-11-09  3:01 ` [PATCH v8 3/6] x86/time: read_boot_clock64() implementation Pavel Tatashin
2017-11-09  3:01 ` Pavel Tatashin [this message]
2017-11-09  3:02 ` [PATCH v8 5/6] x86/paravirt: add active_sched_clock to pv_time_ops Pavel Tatashin
2017-11-09  3:02 ` [PATCH v8 6/6] x86/tsc: use tsc early Pavel Tatashin
2017-11-13  3:47   ` Dou Liyang
2017-11-14 21:46     ` Pavel Tatashin
2017-11-15  3:53       ` Dou Liyang
2017-11-15 16:01         ` Pavel Tatashin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171109030201.5991-5-pasha.tatashin@oracle.com \
    --to=pasha.tatashin@oracle.com \
    --cc=daniel.m.jordan@oracle.com \
    --cc=douly.fnst@cn.fujitsu.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hpa@zytor.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mingo@redhat.com \
    --cc=sboyd@codeaurora.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=steven.sistare@oracle.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®