[RFC patch 1/7] timekeeping: Do not unconditionally suspend NMI safe timekeepers
From: Thomas Gleixner
Date: Wed Nov 15 2017 - 13:28:15 EST
If the current clocksource can be accessed safely after timekeeping is
suspended then there is no reason to suspend the NMI safe timekeepers.
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
include/linux/clocksource.h | 3 ++-
kernel/time/timekeeping.c | 3 +++
2 files changed, 5 insertions(+), 1 deletion(-)
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -119,7 +119,8 @@ struct clocksource {
#define CLOCK_SOURCE_VALID_FOR_HRES 0x20
#define CLOCK_SOURCE_UNSTABLE 0x40
#define CLOCK_SOURCE_SUSPEND_NONSTOP 0x80
-#define CLOCK_SOURCE_RESELECT 0x100
+#define CLOCK_SOURCE_SUSPEND_ACCESS_OK 0x100
+#define CLOCK_SOURCE_RESELECT 0x200
/* simplify initialization of mask field */
#define CLOCKSOURCE_MASK(bits) GENMASK_ULL((bits) - 1, 0)
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -545,6 +545,9 @@ static void halt_fast_timekeeper(struct
static struct tk_read_base tkr_dummy;
struct tk_read_base *tkr = &tk->tkr_mono;
+ if (tkr->clock->flags & CLOCK_SOURCE_SUSPEND_ACCESS_OK)
+ return;
+
memcpy(&tkr_dummy, tkr, sizeof(tkr_dummy));
cycles_at_suspend = tk_clock_read(tkr);
tkr_dummy.clock = &dummy_clock;