linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] time: avoid timespec in udelay_test
@ 2016-06-17 16:03 Arnd Bergmann
  2016-06-17 20:50 ` John Stultz
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2016-06-17 16:03 UTC (permalink / raw)
  To: John Stultz, Thomas Gleixner; +Cc: y2038, Arnd Bergmann, linux-kernel

udelay_test_single() uses ktime_get_ts() to get two timespec values
and calculate the difference between them, while udelay_test_show()
uses the same to printk() the current monotonic time.

Both of these are y2038 safe on all machines, but we want to
get rid of struct timespec anyway, so this converts the code to
use ktime_get_ns() and ktime_get_ts64() respectively.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/time/test_udelay.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/kernel/time/test_udelay.c b/kernel/time/test_udelay.c
index e622ba365a13..b0928ab3270f 100644
--- a/kernel/time/test_udelay.c
+++ b/kernel/time/test_udelay.c
@@ -43,13 +43,13 @@ static int udelay_test_single(struct seq_file *s, int usecs, uint32_t iters)
 	int allowed_error_ns = usecs * 5;
 
 	for (i = 0; i < iters; ++i) {
-		struct timespec ts1, ts2;
+		s64 kt1, kt2;
 		int time_passed;
 
-		ktime_get_ts(&ts1);
+		kt1 = ktime_get_ns();
 		udelay(usecs);
-		ktime_get_ts(&ts2);
-		time_passed = timespec_to_ns(&ts2) - timespec_to_ns(&ts1);
+		kt2 = ktime_get_ns();
+		time_passed = kt2 - kt1;
 
 		if (i == 0 || time_passed < min)
 			min = time_passed;
@@ -87,11 +87,11 @@ static int udelay_test_show(struct seq_file *s, void *v)
 	if (usecs > 0 && iters > 0) {
 		return udelay_test_single(s, usecs, iters);
 	} else if (usecs == 0) {
-		struct timespec ts;
+		struct timespec64 ts;
 
-		ktime_get_ts(&ts);
-		seq_printf(s, "udelay() test (lpj=%ld kt=%ld.%09ld)\n",
-				loops_per_jiffy, ts.tv_sec, ts.tv_nsec);
+		ktime_get_ts64(&ts);
+		seq_printf(s, "udelay() test (lpj=%ld kt=%lld.%09ld)\n",
+				loops_per_jiffy, (s64)ts.tv_sec, ts.tv_nsec);
 		seq_puts(s, "usage:\n");
 		seq_puts(s, "echo USECS [ITERS] > " DEBUGFS_FILENAME "\n");
 		seq_puts(s, "cat " DEBUGFS_FILENAME "\n");
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] time: avoid timespec in udelay_test
  2016-06-17 16:03 [PATCH] time: avoid timespec in udelay_test Arnd Bergmann
@ 2016-06-17 20:50 ` John Stultz
  0 siblings, 0 replies; 2+ messages in thread
From: John Stultz @ 2016-06-17 20:50 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Thomas Gleixner, y2038 Mailman List, lkml

On Fri, Jun 17, 2016 at 9:03 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> udelay_test_single() uses ktime_get_ts() to get two timespec values
> and calculate the difference between them, while udelay_test_show()
> uses the same to printk() the current monotonic time.
>
> Both of these are y2038 safe on all machines, but we want to
> get rid of struct timespec anyway, so this converts the code to
> use ktime_get_ns() and ktime_get_ts64() respectively.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Queued for testing

thanks
-john

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-17 20:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-17 16:03 [PATCH] time: avoid timespec in udelay_test Arnd Bergmann
2016-06-17 20:50 ` John Stultz

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).