[Cbe-oss-dev] [Patch 1/2] spufs: add atomic busy_spus counter to struct cbe_spu_info

Christian Krafft krafft at de.ibm.com
Tue May 27 00:36:24 EST 2008


As nr_active counter includes also spus waiting for syscalls to return
we need a seperate counter that only counts spus that are currently running
on spu side. This counter shall be used by a cpufreq governor that targets
a frequency dependent from the number of running spus.

From: Maxim Shchetynin <maxim at de.ibm.com>
Signed-off-by: Christian Krafft <krafft at de.ibm.com>

Index: linux.git/include/asm-powerpc/spu.h
===================================================================
--- linux.git.orig/include/asm-powerpc/spu.h
+++ linux.git/include/asm-powerpc/spu.h
@@ -192,6 +192,7 @@ struct cbe_spu_info {
 	struct list_head spus;
 	int n_spus;
 	int nr_active;
+	atomic_t busy_spus;
 	atomic_t reserved_spus;
 };
 
Index: linux.git/arch/powerpc/platforms/cell/spufs/sched.c
===================================================================
--- linux.git.orig/arch/powerpc/platforms/cell/spufs/sched.c
+++ linux.git/arch/powerpc/platforms/cell/spufs/sched.c
@@ -980,6 +980,7 @@ void spuctx_switch_state(struct spu_cont
 	struct timespec ts;
 	struct spu *spu;
 	enum spu_utilization_state old_state;
+	int node;
 
 	ktime_get_ts(&ts);
 	curtime = timespec_to_ns(&ts);
@@ -1001,6 +1002,11 @@ void spuctx_switch_state(struct spu_cont
 		spu->stats.times[old_state] += delta;
 		spu->stats.util_state = new_state;
 		spu->stats.tstamp = curtime;
+		node = spu->node;
+		if (old_state == SPU_UTIL_USER)
+			atomic_dec(&cbe_spu_info[node].busy_spus);
+		if (new_state == SPU_UTIL_USER);
+			atomic_inc(&cbe_spu_info[node].busy_spus);
 	}
 }
 


-- 
Mit freundlichen Gruessen,
kind regards,

Christian Krafft
IBM Systems & Technology Group,
Linux Kernel Development
IT Specialist


Vorsitzender des Aufsichtsrats:	Martin Jetter
Geschaeftsfuehrung:		Herbert Kircher
Sitz der Gesellschaft:		Boeblingen
Registriergericht:		Amtsgericht Stuttgart, HRB 243294
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/cbe-oss-dev/attachments/20080526/a4300dd1/attachment.pgp>


More information about the cbe-oss-dev mailing list