summaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/cell/spufs/context.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2007-06-29 02:58:02 +0200
committerPaul Mackerras <paulus@samba.org>2007-07-03 07:24:46 +0200
commit65de66f0b8bcb7431d9df82cf32b002062b3a611 (patch)
treea81eef8195d7f2f1c8c0ad110577b1ca92999c7e /arch/powerpc/platforms/cell/spufs/context.c
parent[POWERPC] spufs: Add tid file (diff)
downloadlinux-65de66f0b8bcb7431d9df82cf32b002062b3a611.tar.xz
linux-65de66f0b8bcb7431d9df82cf32b002062b3a611.zip
[POWERPC] spufs: Implement /proc/spu_loadavg
Provide load average information for spu context. The format is identical to /proc/loadavg, which is also where a lot of code and concepts is borrowed from. 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/context.c')
-rw-r--r--arch/powerpc/platforms/cell/spufs/context.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c
index 6ff2a75589f3..f623d963fdc7 100644
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -23,10 +23,14 @@
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/slab.h>
+#include <asm/atomic.h>
#include <asm/spu.h>
#include <asm/spu_csa.h>
#include "spufs.h"
+
+atomic_t nr_spu_contexts = ATOMIC_INIT(0);
+
struct spu_context *alloc_spu_context(struct spu_gang *gang)
{
struct spu_context *ctx;
@@ -55,6 +59,8 @@ struct spu_context *alloc_spu_context(struct spu_gang *gang)
spu_gang_add_ctx(gang, ctx);
ctx->cpus_allowed = current->cpus_allowed;
spu_set_timeslice(ctx);
+
+ atomic_inc(&nr_spu_contexts);
goto out;
out_free:
kfree(ctx);
@@ -74,6 +80,7 @@ void destroy_spu_context(struct kref *kref)
if (ctx->gang)
spu_gang_remove_ctx(ctx->gang, ctx);
BUG_ON(!list_empty(&ctx->rq));
+ atomic_dec(&nr_spu_contexts);
kfree(ctx);
}