diff mbox series

[RESEND] spufs: use timespec64 for timestamps

Message ID 20180116170053.2557047-1-arnd@arndb.de
State New
Headers show
Series [RESEND] spufs: use timespec64 for timestamps | expand

Commit Message

Arnd Bergmann Jan. 16, 2018, 5 p.m. UTC
The switch log prints the tv_sec portion of timespec as a 32-bit
number, while overflows in 2106. It also uses the timespec type,
which is safe on 64-bit architectures, but deprecated because
it causes overflows in 2038 elsewhere.

This changes it to timespec64 and printing a 64-bit number for
consistency.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
Submitted in November 2017, no reply, resending. Please apply.
---
 arch/powerpc/platforms/cell/spufs/file.c  | 6 +++---
 arch/powerpc/platforms/cell/spufs/spufs.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

-- 
2.9.0

Comments

Jeremy Kerr Jan. 16, 2018, 7:07 p.m. UTC | #1
Hi Arnd,

> The switch log prints the tv_sec portion of timespec as a 32-bit

> number, while overflows in 2106. It also uses the timespec type,

> which is safe on 64-bit architectures, but deprecated because

> it causes overflows in 2038 elsewhere.

> 

> This changes it to timespec64 and printing a 64-bit number for

> consistency.


If we still have spufs in the tree in 2038 I'd be worried :) But good
to keep things consistent.

Acked-by: Jeremy Kerr <jk@ozlabs.org>


Michael: want to take this directly through your tree?

Cheers,


Jeremy
Arnd Bergmann Jan. 16, 2018, 7:58 p.m. UTC | #2
On Tue, Jan 16, 2018 at 8:07 PM, Jeremy Kerr <jk@ozlabs.org> wrote:
> Hi Arnd,

>

>> The switch log prints the tv_sec portion of timespec as a 32-bit

>> number, while overflows in 2106. It also uses the timespec type,

>> which is safe on 64-bit architectures, but deprecated because

>> it causes overflows in 2038 elsewhere.

>>

>> This changes it to timespec64 and printing a 64-bit number for

>> consistency.

>

> If we still have spufs in the tree in 2038 I'd be worried :)


Agreed. My hope is to get rid of 'timespec' in 2018 though, this is just
one of many parts of the puzzle.

         Arnd
Michael Ellerman Jan. 22, 2018, 3:34 a.m. UTC | #3
On Tue, 2018-01-16 at 17:00:35 UTC, Arnd Bergmann wrote:
> The switch log prints the tv_sec portion of timespec as a 32-bit

> number, while overflows in 2106. It also uses the timespec type,

> which is safe on 64-bit architectures, but deprecated because

> it causes overflows in 2038 elsewhere.

> 

> This changes it to timespec64 and printing a 64-bit number for

> consistency.

> 

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> Acked-by: Jeremy Kerr <jk@ozlabs.org>


Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/cef37ac119b1abffcb41a9a7067929

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index fc7772c3d068..c1be486da899 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -2375,8 +2375,8 @@  static int switch_log_sprint(struct spu_context *ctx, char *tbuf, int n)
 
 	p = ctx->switch_log->log + ctx->switch_log->tail % SWITCH_LOG_BUFSIZE;
 
-	return snprintf(tbuf, n, "%u.%09u %d %u %u %llu\n",
-			(unsigned int) p->tstamp.tv_sec,
+	return snprintf(tbuf, n, "%llu.%09u %d %u %u %llu\n",
+			(unsigned long long) p->tstamp.tv_sec,
 			(unsigned int) p->tstamp.tv_nsec,
 			p->spu_id,
 			(unsigned int) p->type,
@@ -2499,7 +2499,7 @@  void spu_switch_log_notify(struct spu *spu, struct spu_context *ctx,
 		struct switch_log_entry *p;
 
 		p = ctx->switch_log->log + ctx->switch_log->head;
-		ktime_get_ts(&p->tstamp);
+		ktime_get_ts64(&p->tstamp);
 		p->timebase = get_tb();
 		p->spu_id = spu ? spu->number : -1;
 		p->type = type;
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index 2d0479ad3af4..b5fc1b3fe538 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -69,7 +69,7 @@  struct switch_log {
 	unsigned long		head;
 	unsigned long		tail;
 	struct switch_log_entry {
-		struct timespec	tstamp;
+		struct timespec64 tstamp;
 		s32		spu_id;
 		u32		type;
 		u32		val;