* [PATCH] ipmi: Change to ktime_get_ts64()
@ 2018-06-18 14:27 Arnd Bergmann
2018-06-18 17:39 ` Corey Minyard
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2018-06-18 14:27 UTC (permalink / raw)
To: Corey Minyard, Arnd Bergmann, Greg Kroah-Hartman
Cc: y2038, openipmi-developer, linux-kernel
getnstimeofday64() is deprecated because of the inconsistent naming,
it is only a wrapper around ktime_get_real_ts64() now, which could be
used as a direct replacement.
However, it is generally better to use CLOCK_MONOTONIC timestamps
where possible, to avoid glitches with a concurrent settimeofday()
or leap second.
The uses in ipmi are either for debugging prints or for comparing against
a prior timestamp, so using a monotonic ktime_get_ts64() is probably
best here.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/char/ipmi/ipmi_si_intf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index ad353be871bf..fb19c796f0fa 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -269,7 +269,7 @@ void debug_timestamp(char *msg)
{
struct timespec64 t;
- getnstimeofday64(&t);
+ ktime_get_ts64(&t);
pr_debug("**%s: %lld.%9.9ld\n", msg, (long long) t.tv_sec, t.tv_nsec);
}
#else
@@ -961,12 +961,12 @@ static inline int ipmi_thread_busy_wait(enum si_sm_result smi_result,
if (max_busy_us == 0 || smi_result != SI_SM_CALL_WITH_DELAY)
ipmi_si_set_not_busy(busy_until);
else if (!ipmi_si_is_busy(busy_until)) {
- getnstimeofday64(busy_until);
+ ktime_get_ts64(busy_until);
timespec64_add_ns(busy_until, max_busy_us*NSEC_PER_USEC);
} else {
struct timespec64 now;
- getnstimeofday64(&now);
+ ktime_get_ts64(&now);
if (unlikely(timespec64_compare(&now, busy_until) > 0)) {
ipmi_si_set_not_busy(busy_until);
return 0;
--
2.9.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ipmi: Change to ktime_get_ts64()
2018-06-18 14:27 [PATCH] ipmi: Change to ktime_get_ts64() Arnd Bergmann
@ 2018-06-18 17:39 ` Corey Minyard
0 siblings, 0 replies; 2+ messages in thread
From: Corey Minyard @ 2018-06-18 17:39 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman; +Cc: y2038, openipmi-developer, linux-kernel
On 06/18/2018 09:27 AM, Arnd Bergmann wrote:
> getnstimeofday64() is deprecated because of the inconsistent naming,
> it is only a wrapper around ktime_get_real_ts64() now, which could be
> used as a direct replacement.
>
> However, it is generally better to use CLOCK_MONOTONIC timestamps
> where possible, to avoid glitches with a concurrent settimeofday()
> or leap second.
>
> The uses in ipmi are either for debugging prints or for comparing against
> a prior timestamp, so using a monotonic ktime_get_ts64() is probably
> best here.
This is definitely better. Queued for 4.19 (or whatever it will be called).
Thanks,
-corey
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/char/ipmi/ipmi_si_intf.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
> index ad353be871bf..fb19c796f0fa 100644
> --- a/drivers/char/ipmi/ipmi_si_intf.c
> +++ b/drivers/char/ipmi/ipmi_si_intf.c
> @@ -269,7 +269,7 @@ void debug_timestamp(char *msg)
> {
> struct timespec64 t;
>
> - getnstimeofday64(&t);
> + ktime_get_ts64(&t);
> pr_debug("**%s: %lld.%9.9ld\n", msg, (long long) t.tv_sec, t.tv_nsec);
> }
> #else
> @@ -961,12 +961,12 @@ static inline int ipmi_thread_busy_wait(enum si_sm_result smi_result,
> if (max_busy_us == 0 || smi_result != SI_SM_CALL_WITH_DELAY)
> ipmi_si_set_not_busy(busy_until);
> else if (!ipmi_si_is_busy(busy_until)) {
> - getnstimeofday64(busy_until);
> + ktime_get_ts64(busy_until);
> timespec64_add_ns(busy_until, max_busy_us*NSEC_PER_USEC);
> } else {
> struct timespec64 now;
>
> - getnstimeofday64(&now);
> + ktime_get_ts64(&now);
> if (unlikely(timespec64_compare(&now, busy_until) > 0)) {
> ipmi_si_set_not_busy(busy_until);
> return 0;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-18 17:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-18 14:27 [PATCH] ipmi: Change to ktime_get_ts64() Arnd Bergmann
2018-06-18 17:39 ` Corey Minyard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).