diff mbox

spufs: initialize ctx->stats.tstamp correctly

Message ID 200902191647.22837.arnd@arndb.de
State Accepted
Headers show

Commit Message

Arnd Bergmann Feb. 19, 2009, 3:47 p.m. UTC
spuctx_switch_state() warns if ktime goes backwards, but it
sometimes compares an uninitialized value, which showed that
the data was unreliable when we actually saw the warning.

Initialize it to the current time in order to get correct data.

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

---
On Tuesday 17 February 2009, Jeremy Kerr wrote:

> Here are a few patches for spufs that I have queued up for 2.6.30.
> Only patch 2/3 should change spufs behaviour - we need to clear
> the pending MFC purge during isolated mode load. The other two patches
> are semantic changes from previous review.

This is another one that came up recently. Please review and send
the same way as the others.
diff mbox

Patch

diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c
index 6653ddb..db5398c 100644
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -35,6 +35,8 @@  atomic_t nr_spu_contexts = ATOMIC_INIT(0);
 struct spu_context *alloc_spu_context(struct spu_gang *gang)
 {
 	struct spu_context *ctx;
+	struct timespec ts;
+
 	ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
 	if (!ctx)
 		goto out;
@@ -64,6 +66,8 @@  struct spu_context *alloc_spu_context(struct spu_gang *gang)
 	__spu_update_sched_info(ctx);
 	spu_set_timeslice(ctx);
 	ctx->stats.util_state = SPU_UTIL_IDLE_LOADED;
+	ktime_get_ts(&ts);
+	ctx->stats.tstamp = timespec_to_ns(&ts);
 
 	atomic_inc(&nr_spu_contexts);
 	goto out;