[PATCH] openvswitch: use ktime_get_ts64() instead of ktime_get_ts()

Subsystems: networking [general], openvswitch, the rest

STALE3183d

4 messages, 3 authors, 2017-11-30 · open the first message on its own page

[PATCH] openvswitch: use ktime_get_ts64() instead of ktime_get_ts()

From: Arnd Bergmann <arnd@arndb.de>
Date: 2017-11-27 11:42:24

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

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

From: Pravin Shelar <hidden>
Date: 2017-11-28 05:05:26

On Mon, Nov 27, 2017 at 5:11 PM, Arnd Bergmann [off-list ref] wrote:
quoted hunk
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

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

From: Arnd Bergmann <arnd@arndb.de>
Date: 2017-11-28 08:50:09

On Tue, Nov 28, 2017 at 5:59 AM, Pravin Shelar [off-list ref] wrote:
On Mon, Nov 27, 2017 at 5:11 PM, Arnd Bergmann [off-list ref] wrote:
quoted
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 <redacted>
---
 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.
It was a micro-optimization that I did to turn a 's64 * constant -> s64'
operation into a cheaper 's32 * constant -> s64' operation. If you
prefer, I can sent it again with a comment, or drop the two
casts.

        Arnd

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

From: David Miller <davem@davemloft.net>
Date: 2017-11-30 14:27:20

From: Arnd Bergmann <redacted>
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 <redacted>
Applied.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help