[Cbe-oss-dev] Gang scheduling [RFC] [PATCH 3:9] inherit scheduling parameters

Luke Browning lukebr at linux.vnet.ibm.com
Sat Mar 15 07:59:30 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.

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>

---

Index: public_git/arch/powerpc/platforms/cell/spufs/gang.c
===================================================================
--- public_git.orig/arch/powerpc/platforms/cell/spufs/gang.c	2008-03-13 20:17:44.000000000 -0300
+++ public_git/arch/powerpc/platforms/cell/spufs/gang.c	2008-03-13 20:19:25.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: public_git/arch/powerpc/platforms/cell/spufs/sched.c
===================================================================
--- public_git.orig/arch/powerpc/platforms/cell/spufs/sched.c	2008-03-13 20:17:44.000000000 -0300
+++ public_git/arch/powerpc/platforms/cell/spufs/sched.c	2008-03-13 20:19:25.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);
 }
 
 /*
@@ -132,6 +134,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
@@ -140,14 +149,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: public_git/arch/powerpc/platforms/cell/spufs/spufs.h
===================================================================
--- public_git.orig/arch/powerpc/platforms/cell/spufs/spufs.h	2008-03-13 20:19:16.000000000 -0300
+++ public_git/arch/powerpc/platforms/cell/spufs/spufs.h	2008-03-13 20:19:25.000000000 -0300
@@ -128,6 +128,11 @@
 	unsigned long flags;
 	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