[Cbe-oss-dev] Gang scheduling [RFC] [PATCH 5:9] faulting

Luke Browning lukebr at linux.vnet.ibm.com
Sat Mar 15 07:59:39 EST 2008


Gang should yield its spu(s) on major page faults.

Implement gang level nfaulting count that is incremented and decremented
across major page faults enabling the gang to be yielded when there are
no runnable contexts in the gang.  If there are no other runnable gangs
waiting to be dispatched, then the gang remains lazily loaded.  Otherwise,
it is switched out and put on the rq. The nrunnable count is the number
of contexts in the gang that are inside spu_run() and are considered
runnable.

Signed-off-by: Luke Browning <lukebrowning at us.ibm.com>

---

Index: public_git/arch/powerpc/platforms/cell/spufs/fault.c
===================================================================
--- public_git.orig/arch/powerpc/platforms/cell/spufs/fault.c	2008-03-06 18:01:53.000000000 -0300
+++ public_git/arch/powerpc/platforms/cell/spufs/fault.c	2008-03-13 21:20:58.000000000 -0300
@@ -144,8 +144,16 @@
 	local_irq_restore(flags);
 
 	/* hashing failed, so try the actual fault handler */
-	if (ret)
+	if (ret) {
+		struct spu_gang *gang = ctx->gang;
+
+		atomic_inc(&gang->nfaulting);
+		if (atomic_read(&gang->nrunnable) ==
+		    atomic_read(&gang->nfaulting))
+			spu_yield(ctx);
 		ret = spu_handle_mm_fault(current->mm, ea, dsisr, &flt);
+		atomic_dec(&gang->nfaulting);
+	}
 
 	/*
 	 * This is nasty: we need the state_mutex for all the bookkeeping even
@@ -161,8 +169,7 @@
 	ctx->csa.dar = ctx->csa.dsisr = 0;
 
 	/*
-	 * If we handled the fault successfully and are in runnable
-	 * state, restart the DMA.
+	 * If we handled the fault successfully, restart the DMA.
 	 * In case of unhandled error report the problem to user space.
 	 */
 	if (!ret) {
Index: public_git/arch/powerpc/platforms/cell/spufs/spufs.h
===================================================================
--- public_git.orig/arch/powerpc/platforms/cell/spufs/spufs.h	2008-03-13 21:17:10.000000000 -0300
+++ public_git/arch/powerpc/platforms/cell/spufs/spufs.h	2008-03-13 21:27:10.000000000 -0300
@@ -134,6 +134,7 @@
 	int prio;
 	atomic_t nstarted;
 	atomic_t nrunnable;
+	atomic_t nfaulting;
 	unsigned long sched_flags;
 	struct list_head rq;





More information about the cbe-oss-dev mailing list