From: tip-bot for Prarit Bhargava <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org,
prarit@redhat.com, sboyd@codeaurora.org, hpa@zytor.com,
mingo@kernel.org, john.stultz@linaro.org, peterz@infradead.org
Subject: [tip:core/printk] timekeeping: Make fast accessors return 0 before timekeeping is initialized
Date: Mon, 25 Sep 2017 12:18:44 -0700 [thread overview]
Message-ID: <tip-5df32107f609c1f621bcdac0a685c23677ef671e@git.kernel.org> (raw)
In-Reply-To: <1503922914-10660-2-git-send-email-prarit@redhat.com>
Commit-ID: 5df32107f609c1f621bcdac0a685c23677ef671e
Gitweb: http://git.kernel.org/tip/5df32107f609c1f621bcdac0a685c23677ef671e
Author: Prarit Bhargava <prarit@redhat.com>
AuthorDate: Mon, 28 Aug 2017 08:21:53 -0400
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 25 Sep 2017 21:05:59 +0200
timekeeping: Make fast accessors return 0 before timekeeping is initialized
printk timestamps will be extended to include mono and boot time by using
the fast timekeeping accessors ktime_get_mono|boot_fast_ns(). The
functions can return garbage before timekeeping is initialized resulting in
garbage timestamps.
Initialize the fast timekeepers with dummy clocks which guarantee a 0
readout up to timekeeping_init().
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/1503922914-10660-2-git-send-email-prarit@redhat.com
---
kernel/time/timekeeping.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 2cafb49..6a92794 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -60,8 +60,27 @@ struct tk_fast {
struct tk_read_base base[2];
};
-static struct tk_fast tk_fast_mono ____cacheline_aligned;
-static struct tk_fast tk_fast_raw ____cacheline_aligned;
+/* Suspend-time cycles value for halted fast timekeeper. */
+static u64 cycles_at_suspend;
+
+static u64 dummy_clock_read(struct clocksource *cs)
+{
+ return cycles_at_suspend;
+}
+
+static struct clocksource dummy_clock = {
+ .read = dummy_clock_read,
+};
+
+static struct tk_fast tk_fast_mono ____cacheline_aligned = {
+ .base[0] = { .clock = &dummy_clock, },
+ .base[1] = { .clock = &dummy_clock, },
+};
+
+static struct tk_fast tk_fast_raw ____cacheline_aligned = {
+ .base[0] = { .clock = &dummy_clock, },
+ .base[1] = { .clock = &dummy_clock, },
+};
/* flag for if timekeeping is suspended */
int __read_mostly timekeeping_suspended;
@@ -477,18 +496,6 @@ u64 notrace ktime_get_boot_fast_ns(void)
}
EXPORT_SYMBOL_GPL(ktime_get_boot_fast_ns);
-/* Suspend-time cycles value for halted fast timekeeper. */
-static u64 cycles_at_suspend;
-
-static u64 dummy_clock_read(struct clocksource *cs)
-{
- return cycles_at_suspend;
-}
-
-static struct clocksource dummy_clock = {
- .read = dummy_clock_read,
-};
-
/**
* halt_fast_timekeeper - Prevent fast timekeeper from accessing clocksource.
* @tk: Timekeeper to snapshot.
next prev parent reply other threads:[~2017-09-25 19:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-28 12:21 [PATCH 0/2 v10] printk: Add new timestamps Prarit Bhargava
2017-08-28 12:21 ` [PATCH 1/2 v10] time: Make fast functions return 0 before timekeeping is initialized Prarit Bhargava
2017-08-28 15:00 ` Thomas Gleixner
2017-09-25 19:18 ` tip-bot for Prarit Bhargava [this message]
2017-08-28 12:21 ` [PATCH 2/2 v10] printk: Add monotonic, boottime, and realtime timestamps Prarit Bhargava
2017-08-31 16:17 ` Thomas Gleixner
2017-09-25 19:19 ` [tip:core/printk] " tip-bot for Prarit Bhargava
2017-09-25 23:50 ` Sergey Senozhatsky
2017-09-26 8:38 ` Thomas Gleixner
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=tip-5df32107f609c1f621bcdac0a685c23677ef671e@git.kernel.org \
--to=tipbot@zytor.com \
--cc=hpa@zytor.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=prarit@redhat.com \
--cc=sboyd@codeaurora.org \
--cc=tglx@linutronix.de \
/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
Powered by JetHome