[Cbe-oss-dev] [PATCH 6/6] spufs: integration of SPE affinity with the scheduler

Andre Detsch adetsch at br.ibm.com
Mon Feb 12 12:17:43 EST 2007


Subject: spufs: integration of SPE affinity with the scheduler
From: Andre Detsch <adetsch at br.ibm.com>

This patch makes the scheduler honor affinity information for each
context being schedulled. If context has no affinity information,
behaviour is unchanged. If there are affinity information, context is
schedulled to be run on the exact spu recommended by the affinity
placement algorithm.


Signed-off-by: Andre Detsch <adetsch at br.ibm.com>

Index: linux-2.6.20/arch/powerpc/platforms/cell/spufs/sched.c
===================================================================
--- linux-2.6.20.orig/arch/powerpc/platforms/cell/spufs/sched.c
+++ linux-2.6.20/arch/powerpc/platforms/cell/spufs/sched.c
@@ -295,6 +295,10 @@ static struct spu *spu_get_idle(struct s
 	int node = cpu_to_node(raw_smp_processor_id());
 	int n;
 
+	spu = affinity_check(ctx);
+	if (spu)
+		return spu_alloc_spu(spu);
+
 	for (n = 0; n < MAX_NUMNODES; n++, node++) {
 		node = (node < MAX_NUMNODES) ? node : 0;
 		if (!node_allowed(node))
Index: linux-2.6.20/arch/powerpc/platforms/cell/spu_base.c
===================================================================
--- linux-2.6.20.orig/arch/powerpc/platforms/cell/spu_base.c
+++ linux-2.6.20/arch/powerpc/platforms/cell/spu_base.c
@@ -365,6 +365,25 @@ static void spu_init_channels(struct spu
 	}
 }
 
+struct spu *spu_alloc_spu(struct spu *req_spu)
+{
+	struct spu *spu, *ret = NULL;
+
+	mutex_lock(&spu_mutex);
+	list_for_each_entry(spu, &be_spu_info[req_spu->node].free_spus, list) {
+		if (spu == req_spu) {
+			list_del_init(&spu->list);
+			pr_debug("Got SPU %d %d\n", spu->number, spu->node);
+			spu_init_channels(spu);
+			ret = spu;
+			break;
+		}
+	}
+	mutex_unlock(&spu_mutex);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(spu_alloc_spu);
+
 struct spu *spu_alloc_node(int node)
 {
 	struct spu *spu = NULL;

--
Andre Detsch



More information about the cbe-oss-dev mailing list