From: Peter Zijlstra <peterz@infradead.org>
To: tglx@linutronix.de, mingo@kernel.org
Cc: linux-kernel@vger.kernel.org, ville.syrjala@linux.intel.com,
daniel.lezcano@linaro.org, rafael.j.wysocki@intel.com,
marta.lofstedt@intel.com, martin.peres@linux.intel.com,
pasha.tatashin@oracle.com, peterz@infradead.org,
daniel.vetter@ffwll.ch
Subject: [PATCH 8/9] sched/clock: Use late_initcall() instead of sched_init_smp()
Date: Fri, 21 Apr 2017 16:58:04 +0200 [thread overview]
Message-ID: <20170421150734.291709551@infradead.org> (raw)
In-Reply-To: <20170421145756.305735607@infradead.org>
[-- Attachment #1: peterz-sched-clock-rubarb-9.patch --]
[-- Type: text/plain, Size: 2607 bytes --]
Core2 marks its TSC unstable in ACPI Processor Idle, which is probed
after sched_init_smp(). Luckily it appears both acpi_processor and
intel_idle (which has a similar check) are mandatory built-in.
This means we can delay switching to stable until after these drivers
have ran (if they were modules, this would be impossible).
Delay the stable switch to late_initcall() to allow these drivers to
mark TSC unstable and avoid difficult stable->unstable transitions.
Cc: "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>
Reported-by: "Lofstedt, Marta" <marta.lofstedt@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/sched/clock.h | 5 -----
kernel/sched/clock.c | 10 +++++++++-
kernel/sched/core.c | 2 --
3 files changed, 9 insertions(+), 8 deletions(-)
--- a/include/linux/sched/clock.h
+++ b/include/linux/sched/clock.h
@@ -23,10 +23,6 @@ extern u64 sched_clock_cpu(int cpu);
extern void sched_clock_init(void);
#ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
-static inline void sched_clock_init_late(void)
-{
-}
-
static inline void sched_clock_tick(void)
{
}
@@ -53,7 +49,6 @@ static inline u64 local_clock(void)
return sched_clock();
}
#else
-extern void sched_clock_init_late(void);
extern int sched_clock_stable(void);
extern void clear_sched_clock_stable(void);
--- a/kernel/sched/clock.c
+++ b/kernel/sched/clock.c
@@ -64,6 +64,7 @@
#include <linux/workqueue.h>
#include <linux/compiler.h>
#include <linux/tick.h>
+#include <linux/init.h>
/*
* Scheduler clock - returns current time in nanosec units.
@@ -203,7 +204,11 @@ void clear_sched_clock_stable(void)
__clear_sched_clock_stable();
}
-void sched_clock_init_late(void)
+/*
+ * 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.
+ */
+static int __init sched_clock_init_late(void)
{
sched_clock_running = 2;
/*
@@ -217,7 +222,10 @@ void sched_clock_init_late(void)
if (__sched_clock_stable_early)
__set_sched_clock_stable();
+
+ return 0;
}
+late_initcall(sched_clock_init_late);
/*
* min, max except they take wrapping into account
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5962,7 +5962,6 @@ void __init sched_init_smp(void)
init_sched_dl_class();
sched_init_smt();
- sched_clock_init_late();
sched_smp_initialized = true;
}
@@ -5978,7 +5977,6 @@ early_initcall(migration_init);
void __init sched_init_smp(void)
{
sched_init_granularity();
- sched_clock_init_late();
}
#endif /* CONFIG_SMP */
next prev parent reply other threads:[~2017-04-21 17:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-21 14:57 [PATCH 0/9] sched_clock fixes Peter Zijlstra
2017-04-21 14:57 ` [PATCH 1/9] x86/tsc: Provide tsc=unstable boot parameter Peter Zijlstra
2017-04-21 14:57 ` [PATCH 2/9] x86,tsc: Feed refined TSC calibration into sched_clock Peter Zijlstra
2017-04-21 14:57 ` [PATCH 3/9] sched/clock: Initialize all per-cpu state before switching (back) to unstable Peter Zijlstra
2017-04-21 14:58 ` [PATCH 4/9] x86/tsc,sched/clock,clocksource: Use clocksource watchdog to provide stable sync points Peter Zijlstra
2017-04-21 14:58 ` [PATCH 5/9] sched/clock: Remove unused argument to sched_clock_idle_wakeup_event() Peter Zijlstra
2017-04-21 14:58 ` [PATCH 6/9] sched/clock: Remove watchdog touching Peter Zijlstra
2017-04-21 15:28 ` Peter Zijlstra
2017-04-21 14:58 ` Peter Zijlstra [this message]
2017-04-21 14:58 ` [PATCH 9/9] sched/clock: Print a warning recommending tsc=unstable Peter Zijlstra
2017-04-25 9:31 ` [PATCH 0/9] sched_clock fixes Lofstedt, Marta
2017-04-25 13:44 ` Peter Zijlstra
2017-04-26 6:41 ` Lofstedt, Marta
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=20170421150734.291709551@infradead.org \
--to=peterz@infradead.org \
--cc=daniel.lezcano@linaro.org \
--cc=daniel.vetter@ffwll.ch \
--cc=linux-kernel@vger.kernel.org \
--cc=marta.lofstedt@intel.com \
--cc=martin.peres@linux.intel.com \
--cc=mingo@kernel.org \
--cc=pasha.tatashin@oracle.com \
--cc=rafael.j.wysocki@intel.com \
--cc=tglx@linutronix.de \
--cc=ville.syrjala@linux.intel.com \
/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®