* [PATCH] openvswitch: use ktime_get_ts64() instead of ktime_get_ts()
@ 2017-11-27 11:41 Arnd Bergmann
2017-11-28 4:59 ` Pravin Shelar
[not found] ` <20171127114159.2528123-1-arnd-r2nGTMty4D4@public.gmane.org>
0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-11-27 11:41 UTC (permalink / raw)
To: Pravin Shelar, David S. Miller
Cc: dev, Willem de Bruijn, Arnd Bergmann, y2038, netdev, Yi-Hung Wei,
Jiri Benc, Pravin B Shelar, Yi Yang, Tonghao Zhang,
Jarno Rajahalme, linux-kernel
timespec is deprecated because of the y2038 overflow, so let's convert
this one to ktime_get_ts64(). The code is already safe even on 32-bit
architectures, since it uses monotonic times. On 64-bit architectures,
nothing changes, while on 32-bit architectures this avoids one
type conversion.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
net/openvswitch/flow.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index dbe2379329c5..76d050aba7a4 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -56,12 +56,12 @@
u64 ovs_flow_used_time(unsigned long flow_jiffies)
{
- struct timespec cur_ts;
+ struct timespec64 cur_ts;
u64 cur_ms, idle_ms;
- ktime_get_ts(&cur_ts);
+ ktime_get_ts64(&cur_ts);
idle_ms = jiffies_to_msecs(jiffies - flow_jiffies);
- cur_ms = (u64)cur_ts.tv_sec * MSEC_PER_SEC +
+ cur_ms = (u64)(u32)cur_ts.tv_sec * MSEC_PER_SEC +
cur_ts.tv_nsec / NSEC_PER_MSEC;
return cur_ms - idle_ms;
--
2.9.0
_______________________________________________
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] openvswitch: use ktime_get_ts64() instead of ktime_get_ts()
2017-11-27 11:41 [PATCH] openvswitch: use ktime_get_ts64() instead of ktime_get_ts() Arnd Bergmann
@ 2017-11-28 4:59 ` Pravin Shelar
[not found] ` <CAOrHB_AqrW=46=YbyMi8LvoFmcTvFXD8epTmJz5DmBNTqOGiCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
[not found] ` <20171127114159.2528123-1-arnd-r2nGTMty4D4@public.gmane.org>
1 sibling, 1 reply; 4+ messages in thread
From: Pravin Shelar @ 2017-11-28 4:59 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Pravin Shelar, David S. Miller, y2038, Tonghao Zhang, Jiri Benc,
Willem de Bruijn, Jarno Rajahalme, Yi-Hung Wei, Yi Yang,
Linux Kernel Network Developers, ovs dev, linux-kernel
On Mon, Nov 27, 2017 at 5:11 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> timespec is deprecated because of the y2038 overflow, so let's convert
> this one to ktime_get_ts64(). The code is already safe even on 32-bit
> architectures, since it uses monotonic times. On 64-bit architectures,
> nothing changes, while on 32-bit architectures this avoids one
> type conversion.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> net/openvswitch/flow.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
> index dbe2379329c5..76d050aba7a4 100644
> --- a/net/openvswitch/flow.c
> +++ b/net/openvswitch/flow.c
> @@ -56,12 +56,12 @@
>
> u64 ovs_flow_used_time(unsigned long flow_jiffies)
> {
> - struct timespec cur_ts;
> + struct timespec64 cur_ts;
> u64 cur_ms, idle_ms;
>
> - ktime_get_ts(&cur_ts);
> + ktime_get_ts64(&cur_ts);
> idle_ms = jiffies_to_msecs(jiffies - flow_jiffies);
> - cur_ms = (u64)cur_ts.tv_sec * MSEC_PER_SEC +
> + cur_ms = (u64)(u32)cur_ts.tv_sec * MSEC_PER_SEC +
I am not sure why is tv_sec converted to u32.
> cur_ts.tv_nsec / NSEC_PER_MSEC;
>
> return cur_ms - idle_ms;
> --
> 2.9.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread[parent not found: <20171127114159.2528123-1-arnd-r2nGTMty4D4@public.gmane.org>]
* Re: [PATCH] openvswitch: use ktime_get_ts64() instead of ktime_get_ts()
[not found] ` <20171127114159.2528123-1-arnd-r2nGTMty4D4@public.gmane.org>
@ 2017-11-30 14:27 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-11-30 14:27 UTC (permalink / raw)
To: arnd-r2nGTMty4D4
Cc: dev-yBygre7rU0TnMu66kgdUjQ, willemb-hpIqsD4AKlfQT0dZR+AlfA,
y2038-cunTk1MwBs8s++Sfvej+rw, netdev-u79uwXL29TY76Z2rM5mHXA,
jbenc-H+wXaHxf7aLQT0dZR+AlfA, pshelar-l0M0P4e3n4LQT0dZR+AlfA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Date: Mon, 27 Nov 2017 12:41:38 +0100
> timespec is deprecated because of the y2038 overflow, so let's convert
> this one to ktime_get_ts64(). The code is already safe even on 32-bit
> architectures, since it uses monotonic times. On 64-bit architectures,
> nothing changes, while on 32-bit architectures this avoids one
> type conversion.
>
> Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-30 14:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-27 11:41 [PATCH] openvswitch: use ktime_get_ts64() instead of ktime_get_ts() Arnd Bergmann
2017-11-28 4:59 ` Pravin Shelar
[not found] ` <CAOrHB_AqrW=46=YbyMi8LvoFmcTvFXD8epTmJz5DmBNTqOGiCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-28 8:50 ` Arnd Bergmann
[not found] ` <20171127114159.2528123-1-arnd-r2nGTMty4D4@public.gmane.org>
2017-11-30 14:27 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox