aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/cell/spufs/file.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2007-06-28 20:58:03 -0400
committerPaul Mackerras <paulus@samba.org>2007-07-03 01:24:46 -0400
commite9f8a0b65ac716fd7974159240ce34bddea780b3 (patch)
tree70e9541861443fc378adc8cc924522e9eb73ab33 /arch/powerpc/platforms/cell/spufs/file.c
parent65de66f0b8bcb7431d9df82cf32b002062b3a611 (diff)
[POWERPC] spufs: Add stat file to spufs
Export per-context statistics in spufs. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/platforms/cell/spufs/file.c')
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 2bb51ca51a6c..30f7b077f347 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -2059,6 +2059,83 @@ static const struct file_operations spufs_tid_fops = {
2059 .release = single_release, 2059 .release = single_release,
2060}; 2060};
2061 2061
2062static const char *ctx_state_names[] = {
2063 "user", "system", "iowait", "loaded"
2064};
2065
2066static unsigned long long spufs_acct_time(struct spu_context *ctx,
2067 enum spuctx_execution_state state)
2068{
2069 unsigned long time = ctx->stats.times[state];
2070
2071 if (ctx->stats.execution_state == state)
2072 time += jiffies - ctx->stats.tstamp;
2073
2074 return jiffies_to_msecs(time);
2075}
2076
2077static unsigned long long spufs_slb_flts(struct spu_context *ctx)
2078{
2079 unsigned long long slb_flts = ctx->stats.slb_flt;
2080
2081 if (ctx->state == SPU_STATE_RUNNABLE) {
2082 slb_flts += (ctx->spu->stats.slb_flt -
2083 ctx->stats.slb_flt_base);
2084 }
2085
2086 return slb_flts;
2087}
2088
2089static unsigned long long spufs_class2_intrs(struct spu_context *ctx)
2090{
2091 unsigned long long class2_intrs = ctx->stats.class2_intr;
2092
2093 if (ctx->state == SPU_STATE_RUNNABLE) {
2094 class2_intrs += (ctx->spu->stats.class2_intr -
2095 ctx->stats.class2_intr_base);
2096 }
2097
2098 return class2_intrs;
2099}
2100
2101
2102static int spufs_show_stat(struct seq_file *s, void *private)
2103{
2104 struct spu_context *ctx = s->private;
2105
2106 spu_acquire(ctx);
2107 seq_printf(s, "%s %llu %llu %llu %llu "
2108 "%llu %llu %llu %llu %llu %llu %llu %llu\n",
2109 ctx_state_names[ctx->stats.execution_state],
2110 spufs_acct_time(ctx, SPUCTX_UTIL_USER),
2111 spufs_acct_time(ctx, SPUCTX_UTIL_SYSTEM),
2112 spufs_acct_time(ctx, SPUCTX_UTIL_IOWAIT),
2113 spufs_acct_time(ctx, SPUCTX_UTIL_LOADED),
2114 ctx->stats.vol_ctx_switch,
2115 ctx->stats.invol_ctx_switch,
2116 spufs_slb_flts(ctx),
2117 ctx->stats.hash_flt,
2118 ctx->stats.min_flt,
2119 ctx->stats.maj_flt,
2120 spufs_class2_intrs(ctx),
2121 ctx->stats.libassist);
2122 spu_release(ctx);
2123 return 0;
2124}
2125
2126static int spufs_stat_open(struct inode *inode, struct file *file)
2127{
2128 return single_open(file, spufs_show_stat, SPUFS_I(inode)->i_ctx);
2129}
2130
2131static const struct file_operations spufs_stat_fops = {
2132 .open = spufs_stat_open,
2133 .read = seq_read,
2134 .llseek = seq_lseek,
2135 .release = single_release,
2136};
2137
2138
2062struct tree_descr spufs_dir_contents[] = { 2139struct tree_descr spufs_dir_contents[] = {
2063 { "capabilities", &spufs_caps_fops, 0444, }, 2140 { "capabilities", &spufs_caps_fops, 0444, },
2064 { "mem", &spufs_mem_fops, 0666, }, 2141 { "mem", &spufs_mem_fops, 0666, },
@@ -2093,6 +2170,7 @@ struct tree_descr spufs_dir_contents[] = {
2093 { "dma_info", &spufs_dma_info_fops, 0444, }, 2170 { "dma_info", &spufs_dma_info_fops, 0444, },
2094 { "proxydma_info", &spufs_proxydma_info_fops, 0444, }, 2171 { "proxydma_info", &spufs_proxydma_info_fops, 0444, },
2095 { "tid", &spufs_tid_fops, 0444, }, 2172 { "tid", &spufs_tid_fops, 0444, },
2173 { "stat", &spufs_stat_fops, 0444, },
2096 {}, 2174 {},
2097}; 2175};
2098 2176
@@ -2117,6 +2195,7 @@ struct tree_descr spufs_dir_nosched_contents[] = {
2117 { "phys-id", &spufs_id_ops, 0666, }, 2195 { "phys-id", &spufs_id_ops, 0666, },
2118 { "object-id", &spufs_object_id_ops, 0666, }, 2196 { "object-id", &spufs_object_id_ops, 0666, },
2119 { "tid", &spufs_tid_fops, 0444, }, 2197 { "tid", &spufs_tid_fops, 0444, },
2198 { "stat", &spufs_stat_fops, 0444, },
2120 {}, 2199 {},
2121}; 2200};
2122 2201