[Cbe-oss-dev] [RFC] [PATCH 5:8] SPU Gang Scheduling - set scheduling parameters for gang

Luke Browning lukebr at linux.vnet.ibm.com
Tue Mar 4 06:49:38 EST 2008


Set gang scheduling parameters for the gang.

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

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

---

Index: spufs/arch/powerpc/platforms/cell/spufs/gang.c
===================================================================
--- spufs.orig/arch/powerpc/platforms/cell/spufs/gang.c	2008-02-29 22:57:03.000000000 -0300
+++ spufs/arch/powerpc/platforms/cell/spufs/gang.c	2008-02-29 22:58:37.000000000 -0300
@@ -39,6 +39,16 @@
 	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;
 }
Index: spufs/arch/powerpc/platforms/cell/spufs/sched.c
===================================================================
--- spufs.orig/arch/powerpc/platforms/cell/spufs/sched.c	2008-02-29 22:59:03.000000000 -0300
+++ spufs/arch/powerpc/platforms/cell/spufs/sched.c	2008-02-29 23:10:14.000000000 -0300
@@ -95,10 +95,12 @@
  */
 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);
 }
 
 /*
@@ -126,6 +128,13 @@
 	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
@@ -134,14 +143,18 @@
 	 * 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.
+	 */
 }
 
 void spu_update_sched_info(struct spu_context *ctx)
 {
-	int node;
-
 	if (ctx->state == SPU_STATE_RUNNABLE) {
-		node = ctx->spu->node;
+		int node = ctx->spu->node;
 
 		/*
 		 * Take list_lock to sync with find_victim().
Index: spufs/arch/powerpc/platforms/cell/spufs/spufs.h
===================================================================
--- spufs.orig/arch/powerpc/platforms/cell/spufs/spufs.h	2008-02-29 22:56:11.000000000 -0300
+++ spufs/arch/powerpc/platforms/cell/spufs/spufs.h	2008-02-29 22:56:48.000000000 -0300
@@ -126,6 +126,11 @@
 	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;





More information about the cbe-oss-dev mailing list