diff mbox

(no subject)

Message ID 200812101903.mBAJ3Hqd013186@d24av01.br.ibm.com
State Superseded
Headers show

Commit Message

Andre Detsch Dec. 10, 2008, 7:03 p.m. UTC
From f262811877f3e35248f49f848e9b60507f4ac44c Mon Sep 17 00:00:00 2001
In-Reply-To: <200812101654.05091.adetsch@br.ibm.com>
References: <200812101654.05091.adetsch@br.ibm.com>
From: Andre Detsch <adetsch@br.ibm.com>
Date: Wed, 10 Dec 2008 16:03:17 -0300
Subject: [PATCH 08/18] powerpc/spufs: Add zombie statistics for gang scheduling
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200812101703.17176.adetsch@br.ibm.com>

Harvest statistics for contexts when they terminate so that perf tools may
show lifetime statistics for gangs.  Active statistics must be obtained
from the context structures as before.  It is too expensive from a locking
perspective to add these statistics to the gang structure when they are
incremented, so just collect them for terminated contexts.

Signed-off-by: Luke Browning <lukebrowning@us.ibm.com>
Signed-off-by: Andre Detsch <adetsch@br.ibm.com>
---
 arch/powerpc/platforms/cell/spufs/gang.c  |   17 +++++++++++++++++
 arch/powerpc/platforms/cell/spufs/spufs.h |   17 +++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/arch/powerpc/platforms/cell/spufs/gang.c 
b/arch/powerpc/platforms/cell/spufs/gang.c
index 3fcbdc7..c64d0ad 100644
--- a/arch/powerpc/platforms/cell/spufs/gang.c
+++ b/arch/powerpc/platforms/cell/spufs/gang.c
@@ -82,6 +82,22 @@  void spu_gang_add_ctx(struct spu_gang *gang, struct 
spu_context *ctx)
 	mutex_unlock(&gang->mutex);
 }
 
+void update_gang_stats(struct spu_gang *gang, struct spu_context *ctx)
+{
+	int i;
+
+	for (i = 0; i < SPU_UTIL_MAX; i++)
+		gang->stats.times[i] += ctx->stats.times[i];
+	gang->stats.vol_ctx_switch += ctx->stats.vol_ctx_switch;
+	gang->stats.invol_ctx_switch += ctx->stats.invol_ctx_switch;
+	gang->stats.min_flt += ctx->stats.min_flt;
+	gang->stats.maj_flt += ctx->stats.maj_flt;
+	gang->stats.hash_flt += ctx->stats.hash_flt;
+	gang->stats.slb_flt += ctx->stats.slb_flt;
+	gang->stats.class2_intr += ctx->stats.class2_intr;
+	gang->stats.libassist += ctx->stats.libassist;
+}
+
 void spu_gang_remove_ctx(struct spu_gang *gang, struct spu_context *ctx)
 {
 	mutex_lock(&gang->mutex);
@@ -92,6 +108,7 @@  void spu_gang_remove_ctx(struct spu_gang *gang, struct 
spu_context *ctx)
 	}
 	list_del_init(&ctx->gang_list);
 	gang->contexts--;
+	update_gang_stats(gang, ctx);
 	atomic_dec(&gang->nstarted);
 	if (spu_gang_runnable(gang)) {
 		ctx = list_first_entry(&gang->list,
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h 
b/arch/powerpc/platforms/cell/spufs/spufs.h
index c041cce..952272f 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -178,6 +178,23 @@  struct spu_gang {
 	int aff_flags;
 	struct spu *aff_ref_spu;
 	atomic_t aff_sched_count;
+
+	/* spu scheduler statistics for zombie ctxts */
+	struct {
+		enum spu_utilization_state util_state;		/* N/A */
+		unsigned long long tstamp;			/* N/A */
+		unsigned long long times[SPU_UTIL_MAX];
+		unsigned long long vol_ctx_switch;
+		unsigned long long invol_ctx_switch;
+		unsigned long long min_flt;
+		unsigned long long maj_flt;
+		unsigned long long hash_flt;
+		unsigned long long slb_flt;
+		unsigned long long slb_flt_base;		/* N/A */
+		unsigned long long class2_intr;
+		unsigned long long class2_intr_base;		/* N/A */
+		unsigned long long libassist;
+	} stats;
 };
 
 static inline int spu_gang_runnable(struct spu_gang *g)