[Cbe-oss-dev] Gang scheduling [RFC] [PATCH 8:9] statistics

Luke Browning lukebr at linux.vnet.ibm.com
Sat Mar 15 08:00:06 EST 2008


Add zombie statistics for gang scheduling

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 at us.ibm.com>

---

Index: public_git/arch/powerpc/platforms/cell/spufs/spufs.h
===================================================================
--- public_git.orig/arch/powerpc/platforms/cell/spufs/spufs.h	2008-03-13 21:43:13.000000000 -0300
+++ public_git/arch/powerpc/platforms/cell/spufs/spufs.h	2008-03-13 22:22:28.000000000 -0300
@@ -145,6 +145,23 @@
 	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)
Index: public_git/arch/powerpc/platforms/cell/spufs/gang.c
===================================================================
--- public_git.orig/arch/powerpc/platforms/cell/spufs/gang.c	2008-03-13 22:12:09.000000000 -0300
+++ public_git/arch/powerpc/platforms/cell/spufs/gang.c	2008-03-13 22:25:48.000000000 -0300
@@ -84,6 +84,22 @@
 	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);
@@ -94,6 +110,7 @@
 	}
 	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,





More information about the cbe-oss-dev mailing list