aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/cell/spufs/spufs.h
diff options
context:
space:
mode:
authorAndre Detsch <adetsch@br.ibm.com>2007-07-20 15:39:33 -0400
committerArnd Bergmann <arnd@klappe.arndb.de>2007-07-20 15:41:50 -0400
commit27ec41d3a1d4df2b7cd190e93aad22ab86a72aa1 (patch)
tree6c9d5af3fc3c3cfbef390eb34caf4dc7e7a3913e /arch/powerpc/platforms/cell/spufs/spufs.h
parente840cfe6814d6f13ecb86cff7097ad7259df502e (diff)
[CELL] spufs: add spu stats in sysfs and ctx stat file in spufs
This patch exports per-context statistics in spufs as long as spu statistics in sysfs. It was formed by merging: "spufs: add spu stats in sysfs" From: Christoph Hellwig "spufs: add stat file to spufs" From: Christoph Hellwig "spufs: fix libassist accounting" From: Jeremy Kerr "spusched: fix spu utilization statistics" From: Luke Browning And some adjustments by myself, after suggestions on cbe-oss-dev. Having separate patches was making the review process harder than it should, as we end up integrating spus and ctx statistics accounting much more than it was on the first implementation. Signed-off-by: Andre Detsch <adetsch@br.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Diffstat (limited to 'arch/powerpc/platforms/cell/spufs/spufs.h')
-rw-r--r--arch/powerpc/platforms/cell/spufs/spufs.h63
1 files changed, 27 insertions, 36 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index 34d5f9f8b4a..fdace928437 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -40,19 +40,6 @@ enum {
40struct spu_context_ops; 40struct spu_context_ops;
41struct spu_gang; 41struct spu_gang;
42 42
43/*
44 * This is the state for spu utilization reporting to userspace.
45 * Because this state is visible to userspace it must never change and needs
46 * to be kept strictly separate from any internal state kept by the kernel.
47 */
48enum spuctx_execution_state {
49 SPUCTX_UTIL_USER = 0,
50 SPUCTX_UTIL_SYSTEM,
51 SPUCTX_UTIL_IOWAIT,
52 SPUCTX_UTIL_LOADED,
53 SPUCTX_UTIL_MAX
54};
55
56struct spu_context { 43struct spu_context {
57 struct spu *spu; /* pointer to a physical SPU */ 44 struct spu *spu; /* pointer to a physical SPU */
58 struct spu_state csa; /* SPU context save area. */ 45 struct spu_state csa; /* SPU context save area. */
@@ -104,9 +91,9 @@ struct spu_context {
104 /* statistics */ 91 /* statistics */
105 struct { 92 struct {
106 /* updates protected by ctx->state_mutex */ 93 /* updates protected by ctx->state_mutex */
107 enum spuctx_execution_state execution_state; 94 enum spu_utilization_state util_state;
108 unsigned long tstamp; /* time of last ctx switch */ 95 unsigned long long tstamp; /* time of last state switch */
109 unsigned long times[SPUCTX_UTIL_MAX]; 96 unsigned long long times[SPU_UTIL_MAX];
110 unsigned long long vol_ctx_switch; 97 unsigned long long vol_ctx_switch;
111 unsigned long long invol_ctx_switch; 98 unsigned long long invol_ctx_switch;
112 unsigned long long min_flt; 99 unsigned long long min_flt;
@@ -293,30 +280,34 @@ extern int spufs_coredump_num_notes;
293 * line. 280 * line.
294 */ 281 */
295static inline void spuctx_switch_state(struct spu_context *ctx, 282static inline void spuctx_switch_state(struct spu_context *ctx,
296 enum spuctx_execution_state new_state) 283 enum spu_utilization_state new_state)
297{ 284{
298 WARN_ON(!mutex_is_locked(&ctx->state_mutex)); 285 unsigned long long curtime;
286 signed long long delta;
287 struct timespec ts;
288 struct spu *spu;
289 enum spu_utilization_state old_state;
299 290
300 if (ctx->stats.execution_state != new_state) { 291 ktime_get_ts(&ts);
301 unsigned long curtime = jiffies; 292 curtime = timespec_to_ns(&ts);
293 delta = curtime - ctx->stats.tstamp;
302 294
303 ctx->stats.times[ctx->stats.execution_state] += 295 WARN_ON(!mutex_is_locked(&ctx->state_mutex));
304 curtime - ctx->stats.tstamp; 296 WARN_ON(delta < 0);
305 ctx->stats.tstamp = curtime; 297
306 ctx->stats.execution_state = new_state; 298 spu = ctx->spu;
307 } 299 old_state = ctx->stats.util_state;
308} 300 ctx->stats.util_state = new_state;
309 301 ctx->stats.tstamp = curtime;
310static inline void spu_switch_state(struct spu *spu, 302
311 enum spuctx_execution_state new_state) 303 /*
312{ 304 * Update the physical SPU utilization statistics.
313 if (spu->stats.utilization_state != new_state) { 305 */
314 unsigned long curtime = jiffies; 306 if (spu) {
315 307 ctx->stats.times[old_state] += delta;
316 spu->stats.times[spu->stats.utilization_state] += 308 spu->stats.times[old_state] += delta;
317 curtime - spu->stats.tstamp; 309 spu->stats.util_state = new_state;
318 spu->stats.tstamp = curtime; 310 spu->stats.tstamp = curtime;
319 spu->stats.utilization_state = new_state;
320 } 311 }
321} 312}
322 313