From patchwork Thu Sep 11 23:38:19 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: powerpc/spufs: Add zombie statistics for gang scheduling From: Andre Detsch X-Patchwork-Id: 256 Message-Id: <200809112038.19772.adetsch@br.ibm.com> To: cbe-oss-dev@ozlabs.org Cc: LukeBrowning@us.ibm.com, Jeremy Kerr Date: Thu, 11 Sep 2008 20:38:19 -0300 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 Signed-off-by: Andre Detsch 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 bc3b499..de436f2 100644 --- a/arch/powerpc/platforms/cell/spufs/spufs.h +++ b/arch/powerpc/platforms/cell/spufs/spufs.h @@ -179,6 +179,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)