[Cbe-oss-dev] [PATCH 03/18] powerpc/spufs: Set gang scheduling parameters for the gang.

Andre Detsch adetsch at br.ibm.com
Thu Dec 11 06:40:39 EST 2008


Priority, policy, and NUMA cpu mask are inherited from the thread
that creates the first context.

Note a follow on patch will implement effective priority and policy
parameters that are derived from each thread.

Signed-off-by: Luke Browning <lukebrowning at us.ibm.com>
Signed-off-by: Andre Detsch <adetsch at br.ibm.com>
---
 arch/powerpc/platforms/cell/spufs/gang.c  |   10 ++++++++++
 arch/powerpc/platforms/cell/spufs/sched.c |   21 ++++++++++++++++++---
 arch/powerpc/platforms/cell/spufs/spufs.h |    5 +++++
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/cell/spufs/gang.c b/arch/powerpc/platforms/cell/spufs/gang.c
index 71a4432..2a01271 100644
--- a/arch/powerpc/platforms/cell/spufs/gang.c
+++ b/arch/powerpc/platforms/cell/spufs/gang.c
@@ -39,6 +39,16 @@ struct spu_gang *alloc_spu_gang(void)
 	INIT_LIST_HEAD(&gang->list);
 	INIT_LIST_HEAD(&gang->aff_list_head);
 
+	/*
+	 * Inherit scheduling parameters from the creator of the gang.
+	 */
+	if (rt_prio(current->prio))
+		gang->prio = current->prio;
+	else
+		gang->prio = current->static_prio;
+	gang->policy = current->policy;
+	gang->cpus_allowed = current->cpus_allowed;
+
 out:
 	return gang;
 }
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 8ebbf05..1fc0c3d 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -95,10 +95,12 @@ static struct timer_list spuloadavg_timer;
  */
 void spu_set_timeslice(struct spu_context *ctx)
 {
-	if (ctx->prio < NORMAL_PRIO)
-		ctx->time_slice = SCALE_PRIO(DEF_SPU_TIMESLICE * 4, ctx->prio);
+	struct spu_gang *gang = ctx->gang;
+
+	if (gang->prio < NORMAL_PRIO)
+		ctx->time_slice = SCALE_PRIO(DEF_SPU_TIMESLICE * 4, gang->prio);
 	else
-		ctx->time_slice = SCALE_PRIO(DEF_SPU_TIMESLICE, ctx->prio);
+		ctx->time_slice = SCALE_PRIO(DEF_SPU_TIMESLICE, gang->prio);
 }
 
 /*
@@ -132,6 +134,13 @@ static void __spu_update_sched_info(struct spu_context *ctx)
 	ctx->policy = current->policy;
 
 	/*
+	 * TO DO: effective gang priorities.  Currently, the gang's priority
+	 * is inherited from the thread that allocates the gang structure.
+	 * Therefore, it never changes.  It should be based on the dynamic
+	 * value of the controlling threads.
+	 */
+
+	/*
 	 * TO DO: the context may be loaded, so we may need to activate
 	 * it again on a different node. But it shouldn't hurt anything
 	 * to update its parameters, because we know that the scheduler
@@ -141,6 +150,12 @@ static void __spu_update_sched_info(struct spu_context *ctx)
 	 */
 	ctx->cpus_allowed = current->cpus_allowed;
 
+	/*
+	 * TO DO: NUMA gang scheduling. The placement of the gang onto spus
+	 * is based on the value of the cpus_allowed field of the thread
+	 * that created the gang. It should be dynamic too.  eww.
+	 */
+
 	/* Save the current cpu id for spu interrupt routing. */
 	ctx->last_ran = raw_smp_processor_id();
 }
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index cb42aee..a8f5203 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -161,6 +161,11 @@ struct spu_gang {
 	struct kref kref;
 	int contexts;
 
+	/* scheduler fields */
+	cpumask_t cpus_allowed;
+	int policy;
+	int prio;
+
 	struct spu_context *aff_ref_ctx;
 	struct list_head aff_list_head;
 	struct mutex aff_mutex;
-- 
1.5.4.3







More information about the cbe-oss-dev mailing list