From: tip-bot for Arnd Bergmann <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com,
sboyd@codeaurora.org, arnd@arndb.de, tony.luck@intel.com,
john.stultz@linaro.org, keescook@chromium.org,
tglx@linutronix.de, mingo@kernel.org, ccross@android.com,
anton@enomsg.org
Subject: [tip:timers/core] pstore: Use ktime_get_real_fast_ns() instead of __getnstimeofday()
Date: Sun, 12 Nov 2017 06:10:28 -0800 [thread overview]
Message-ID: <tip-df27067e6040b51188184876253d93da002433aa@git.kernel.org> (raw)
In-Reply-To: <20171110152530.1926955-1-arnd@arndb.de>
Commit-ID: df27067e6040b51188184876253d93da002433aa
Gitweb: https://git.kernel.org/tip/df27067e6040b51188184876253d93da002433aa
Author: Arnd Bergmann <arnd@arndb.de>
AuthorDate: Fri, 10 Nov 2017 16:25:04 +0100
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 12 Nov 2017 15:05:52 +0100
pstore: Use ktime_get_real_fast_ns() instead of __getnstimeofday()
__getnstimeofday() is a rather odd interface, with a number of quirks:
- The caller may come from NMI context, but the implementation is not NMI safe,
one way to get there from NMI is
NMI handler:
something bad
panic()
kmsg_dump()
pstore_dump()
pstore_record_init()
__getnstimeofday()
- The calling conventions are different from any other timekeeping functions,
to deal with returning an error code during suspended timekeeping.
Address the above issues by using a completely different method to get the
time: ktime_get_real_fast_ns() is NMI safe and has a reasonable behavior
when timekeeping is suspended: it returns the time at which it got
suspended. As Thomas Gleixner explained, this is safe, as
ktime_get_real_fast_ns() does not call into the clocksource driver that
might be suspended.
The result can easily be transformed into a timespec structure. Since
ktime_get_real_fast_ns() was not exported to modules, add the export.
The pstore behavior for the suspended case changes slightly, as it now
stores the timestamp at which timekeeping was suspended instead of storing
a zero timestamp.
This change is not addressing y2038-safety, that's subject to a more
complex follow up patch.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Anton Vorontsov <anton@enomsg.org>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Colin Cross <ccross@android.com>
Link: https://lkml.kernel.org/r/20171110152530.1926955-1-arnd@arndb.de
---
fs/pstore/platform.c | 5 +----
kernel/time/timekeeping.c | 1 +
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index ec7199e..086e491 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -482,10 +482,7 @@ void pstore_record_init(struct pstore_record *record,
record->psi = psinfo;
/* Report zeroed timestamp if called before timekeeping has resumed. */
- if (__getnstimeofday(&record->time)) {
- record->time.tv_sec = 0;
- record->time.tv_nsec = 0;
- }
+ record->time = ns_to_timespec(ktime_get_real_fast_ns());
}
/*
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 353f7bd..198afa7 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -528,6 +528,7 @@ u64 ktime_get_real_fast_ns(void)
{
return __ktime_get_real_fast_ns(&tk_fast_mono);
}
+EXPORT_SYMBOL_GPL(ktime_get_real_fast_ns);
/**
* halt_fast_timekeeper - Prevent fast timekeeper from accessing clocksource.
prev parent reply other threads:[~2017-11-12 14:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-10 15:25 [PATCH] [v2] pstore: use " Arnd Bergmann
2017-11-10 19:38 ` Kees Cook
2017-11-10 21:27 ` Thomas Gleixner
2017-11-12 14:10 ` tip-bot for Arnd Bergmann [this message]
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-df27067e6040b51188184876253d93da002433aa@git.kernel.org \
--to=tipbot@zytor.com \
--cc=anton@enomsg.org \
--cc=arnd@arndb.de \
--cc=ccross@android.com \
--cc=hpa@zytor.com \
--cc=john.stultz@linaro.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=sboyd@codeaurora.org \
--cc=tglx@linutronix.de \
--cc=tony.luck@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
Powered by JetHome