diff mbox

[12/18] powerpc/spufs: Concentrate scheduling attributes in gang structure

Message ID 200812101740.48087.adetsch@br.ibm.com
State RFC
Headers show

Commit Message

Andre Detsch Dec. 10, 2008, 7:40 p.m. UTC
Remove spus_allowed, policy and prio attributes from SPU context.
Use attributes from the gang instead.

Signed-off-by: Andre Detsch <adetsch@br.ibm.com>
---
 arch/powerpc/platforms/cell/spufs/context.c |    1 -
 arch/powerpc/platforms/cell/spufs/file.c    |    2 +-
 arch/powerpc/platforms/cell/spufs/gang.c    |   14 +++++
 arch/powerpc/platforms/cell/spufs/run.c     |   10 +++-
 arch/powerpc/platforms/cell/spufs/sched.c   |   73 +--------------------------
 arch/powerpc/platforms/cell/spufs/spufs.h   |    4 --
 6 files changed, 26 insertions(+), 78 deletions(-)
diff mbox

Patch

diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c
index 11b9237..3bda369 100644
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -102,7 +102,6 @@  struct spu_context *alloc_spu_context(struct spu_gang *gang)
 	ctx->owner = get_task_mm(current);
 	INIT_LIST_HEAD(&ctx->aff_list);
 	spu_gang_add_ctx(gang, ctx);
-	spu_update_sched_info(ctx);
 	spu_set_timeslice(ctx);
 	ctx->stats.util_state = SPU_UTIL_IDLE_LOADED;
 
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index a02ee25..dbd1058 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -2646,7 +2646,7 @@  static int spufs_show_ctx(struct seq_file *s, void *private)
 		ctx->state == SPU_STATE_SAVED ? 'S' : 'R',
 		ctx->flags,
 		ctx->sched_flags,
-		ctx->prio,
+		ctx->gang->prio,
 		ctx->time_slice,
 		ctx->spu ? ctx->spu->number : -1,
 		!list_empty(&ctx->gang->rq) ? 'q' : ' ',
diff --git a/arch/powerpc/platforms/cell/spufs/gang.c b/arch/powerpc/platforms/cell/spufs/gang.c
index c64d0ad..7b1513d 100644
--- a/arch/powerpc/platforms/cell/spufs/gang.c
+++ b/arch/powerpc/platforms/cell/spufs/gang.c
@@ -43,11 +43,25 @@  struct spu_gang *alloc_spu_gang(void)
 	/*
 	 * Inherit scheduling parameters from the creator of the gang.
 	 */
+
+	/*
+	 * We do our own priority calculations, so we normally want
+	 * ->static_prio to start with. Unfortunately this field
+	 * contains junk for threads with a realtime scheduling
+	 * policy so we have to look at ->prio in this case.
+	 */
 	if (rt_prio(current->prio))
 		gang->prio = current->prio;
 	else
 		gang->prio = current->static_prio;
+
 	gang->policy = current->policy;
+
+	/*
+	 * 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.
+	 */
 	gang->cpus_allowed = current->cpus_allowed;
 
 out:
diff --git a/arch/powerpc/platforms/cell/spufs/run.c b/arch/powerpc/platforms/cell/spufs/run.c
index cbce273..b351230 100644
--- a/arch/powerpc/platforms/cell/spufs/run.c
+++ b/arch/powerpc/platforms/cell/spufs/run.c
@@ -409,7 +409,15 @@  long spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *event)
 
 	spu_enable_spu(ctx);
 
-	spu_update_sched_info(ctx);
+	/*
+	 * 32-Bit assignments are atomic on powerpc, and we don't care about
+	 * memory ordering here because retrieving the controlling thread is
+	 * per definition racy.
+	 */
+	ctx->tid = current->pid;
+
+	/* Save the current cpu id for spu interrupt routing. */
+	ctx->last_ran = raw_smp_processor_id();
 
 	ret = spu_run_init(ctx, npc);
 	if (ret) {
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 5289cdb..be13b19 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -143,75 +143,6 @@  void spu_set_timeslice(struct spu_context *ctx)
 		ctx->time_slice = SCALE_PRIO(DEF_SPU_TIMESLICE, gang->prio);
 }
 
-/*
- * Update scheduling information from the owning thread.
- */
-static void __spu_update_sched_info(struct spu_context *ctx)
-{
-	/*
-	 * 32-Bit assignments are atomic on powerpc, and we don't care about
-	 * memory ordering here because retrieving the controlling thread is
-	 * per definition racy.
-	 */
-	ctx->tid = current->pid;
-
-	/*
-	 * We do our own priority calculations, so we normally want
-	 * ->static_prio to start with. Unfortunately this field
-	 * contains junk for threads with a realtime scheduling
-	 * policy so we have to look at ->prio in this case.
-	 */
-	if (rt_prio(current->prio))
-		ctx->prio = current->prio;
-	else
-		ctx->prio = current->static_prio;
-	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
-	 * is not actively looking at this field, since it is not on the
-	 * runqueue. The context will be rescheduled on the proper node
-	 * if it is timesliced or preempted.
-	 */
-	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();
-}
-
-void spu_update_sched_info(struct spu_context *ctx)
-{
-	int node;
-
-	if (ctx->state == SPU_STATE_RUNNABLE) {
-		node = ctx->spu->node;
-
-		/*
-		 * Take list_mutex to sync with find_victim().
-		 */
-		mutex_lock(&cbe_spu_info[node].list_mutex);
-		__spu_update_sched_info(ctx);
-		mutex_unlock(&cbe_spu_info[node].list_mutex);
-	} else {
-		__spu_update_sched_info(ctx);
-	}
-}
-
 static int __node_allowed(struct spu_gang *gang, int node)
 {
 	if (nr_cpus_node(node)) {
@@ -1246,7 +1177,7 @@  static noinline int spusched_tick(struct spu_gang *gang,
 	 */
 	yield = atomic_read(&gang->nrunnable) == atomic_read(&gang->nfaulting);
 
-	if (yield || ((ctx->policy != SCHED_FIFO) && (!--ctx->time_slice))) {
+	if (yield || ((gang->policy != SCHED_FIFO) && (!--ctx->time_slice))) {
 		if (spu_prio->nr_waiting) {
 			best = find_first_bit(spu_prio->bitmap, gang->prio);
 			if (yield || (preempt && best <= gang->prio)) {
@@ -1259,7 +1190,7 @@  static noinline int spusched_tick(struct spu_gang *gang,
 			}
 		}
 		spu_context_nospu_trace(spusched_tick__newslice, ctx);
-		if (ctx->policy != SCHED_FIFO)
+		if (gang->policy != SCHED_FIFO)
 			ctx->time_slice++;
 	}
 out:
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index 468ee37..bfe4098 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -124,9 +124,6 @@  struct spu_context {
 	/* scheduler fields */
 	unsigned int time_slice;
 	unsigned long sched_flags;
-	cpumask_t cpus_allowed;
-	int policy;
-	int prio;
 	int last_ran;
 
 	/* statistics */
@@ -343,7 +340,6 @@  void spu_switch_notify(struct spu *spu, struct spu_context *ctx);
 void spu_switch_log_notify(struct spu *spu, struct spu_context *ctx,
 		u32 type, u32 val);
 void spu_set_timeslice(struct spu_context *ctx);
-void spu_update_sched_info(struct spu_context *ctx);
 int __init spu_sched_init(void);
 void spu_sched_exit(void);