diff mbox

powerpc/spufs: Set gang scheduling parameters for the gang.

Message ID 200809112037.49688.adetsch@br.ibm.com
State Superseded
Delegated to: Jeremy Kerr
Headers show

Commit Message

Andre Detsch Sept. 11, 2008, 11:37 p.m. UTC
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@us.ibm.com>
Signed-off-by: Andre Detsch <adetsch@br.ibm.com>
diff mbox

Patch

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 386aa0a..0e29f12 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 @@  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 @@  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 8ae8ef9..03f0a3c 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -162,6 +162,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;