[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-857baa87b6422bcfb84ed3631d6839920cb5b09d@git.kernel.org>
Date: Thu, 19 Jul 2018 15:33:21 -0700
From: tip-bot for Pavel Tatashin <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: pasha.tatashin@...cle.com, linux-kernel@...r.kernel.org,
hpa@...or.com, mingo@...nel.org, tglx@...utronix.de
Subject: [tip:x86/timers] sched/clock: Enable sched clock early
Commit-ID: 857baa87b6422bcfb84ed3631d6839920cb5b09d
Gitweb: https://git.kernel.org/tip/857baa87b6422bcfb84ed3631d6839920cb5b09d
Author: Pavel Tatashin <pasha.tatashin@...cle.com>
AuthorDate: Thu, 19 Jul 2018 16:55:42 -0400
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitDate: Fri, 20 Jul 2018 00:02:43 +0200
sched/clock: Enable sched clock early
Allow sched_clock() to be used before schec_clock_init() is called. This
provides a way to get early boot timestamps on machines with unstable
clocks.
Signed-off-by: Pavel Tatashin <pasha.tatashin@...cle.com>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Cc: steven.sistare@...cle.com
Cc: daniel.m.jordan@...cle.com
Cc: linux@...linux.org.uk
Cc: schwidefsky@...ibm.com
Cc: heiko.carstens@...ibm.com
Cc: john.stultz@...aro.org
Cc: sboyd@...eaurora.org
Cc: hpa@...or.com
Cc: douly.fnst@...fujitsu.com
Cc: peterz@...radead.org
Cc: prarit@...hat.com
Cc: feng.tang@...el.com
Cc: pmladek@...e.com
Cc: gnomes@...rguk.ukuu.org.uk
Cc: linux-s390@...r.kernel.org
Cc: boris.ostrovsky@...cle.com
Cc: jgross@...e.com
Cc: pbonzini@...hat.com
Link: https://lkml.kernel.org/r/20180719205545.16512-24-pasha.tatashin@oracle.com
---
init/main.c | 2 +-
kernel/sched/clock.c | 20 +++++++++++++++++++-
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/init/main.c b/init/main.c
index 162d931c9511..ff0a24170b95 100644
--- a/init/main.c
+++ b/init/main.c
@@ -642,7 +642,6 @@ asmlinkage __visible void __init start_kernel(void)
softirq_init();
timekeeping_init();
time_init();
- sched_clock_init();
printk_safe_init();
perf_event_init();
profile_init();
@@ -697,6 +696,7 @@ asmlinkage __visible void __init start_kernel(void)
acpi_early_init();
if (late_time_init)
late_time_init();
+ sched_clock_init();
calibrate_delay();
pid_idr_init();
anon_vma_init();
diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c
index 0e9dbb2d9aea..422cd63f8f17 100644
--- a/kernel/sched/clock.c
+++ b/kernel/sched/clock.c
@@ -202,7 +202,25 @@ static void __sched_clock_gtod_offset(void)
void __init sched_clock_init(void)
{
+ unsigned long flags;
+
+ /*
+ * Set __gtod_offset such that once we mark sched_clock_running,
+ * sched_clock_tick() continues where sched_clock() left off.
+ *
+ * Even if TSC is buggered, we're still UP at this point so it
+ * can't really be out of sync.
+ */
+ local_irq_save(flags);
+ __sched_clock_gtod_offset();
+ local_irq_restore(flags);
+
sched_clock_running = 1;
+
+ /* Now that sched_clock_running is set adjust scd */
+ local_irq_save(flags);
+ sched_clock_tick();
+ local_irq_restore(flags);
}
/*
* We run this as late_initcall() such that it runs after all built-in drivers,
@@ -356,7 +374,7 @@ u64 sched_clock_cpu(int cpu)
return sched_clock() + __sched_clock_offset;
if (unlikely(!sched_clock_running))
- return 0ull;
+ return sched_clock();
preempt_disable_notrace();
scd = cpu_sdc(cpu);
Powered by blists - more mailing lists