2017-11-28 05:06:21

by Pravin Shelar

[permalink] [raw]
Subject: Re: [PATCH] openvswitch: use ktime_get_ts64() instead of ktime_get_ts()

On Mon, Nov 27, 2017 at 5:11 PM, Arnd Bergmann <[email protected]> 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 <[email protected]>
> ---
> 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
>

From 1585219465523485672@xxx Mon Nov 27 11:44:50 +0000 2017
X-GM-THRID: 1585219465523485672
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread