[Cbe-oss-dev] spufs: small adjustments on affinity placement code

Andre Detsch adetsch at br.ibm.com
Sat May 5 06:24:46 EST 2007


Subject: spufs: small adjustments on affinity placement code
From: Andre Detsch <adetsch at br.ibm.com>

Folllowing suggestions made in cbe-oss-dev:
 * Rename of 'sched_spu' function
 * Usage of list_for_each insted of list_for_each_entry
 * Calling ATOMIC_INIT to initialize gang->aff_sched_count

Signed-off-by: Andre Detsch <adetsch at br.ibm.com>

Index: linux-2.6.21/arch/powerpc/platforms/cell/spufs/sched.c
===================================================================
--- linux-2.6.21.orig/arch/powerpc/platforms/cell/spufs/sched.c
+++ linux-2.6.21/arch/powerpc/platforms/cell/spufs/sched.c
@@ -808,7 +808,7 @@ static void aff_set_offsets(struct spu_g
 	gang->aff_flags |= AFF_OFFSETS_SET;
 }
 
-static inline int sched_spu(struct spu *spu)
+static inline int spu_is_schedulable(struct spu *spu)
 {
 	return (!spu->ctx || !(spu->ctx->flags & SPU_CREATE_NOSCHED));
 }
@@ -830,7 +830,7 @@ aff_ref_location(struct spu_context *ctx
 			continue;
 		list_for_each_entry(spu, &cbe_spu_info[node].spus, cbe_list) {
 			if ((!mem_aff || spu->has_mem_affinity) &&
-							sched_spu(spu))
+						spu_is_schedulable(spu))
 				return spu;
 		}
 	}
@@ -841,12 +841,12 @@ static void aff_set_ref_point_location(s
 {
 	int mem_aff, gs, lowest_offset;
 	struct spu_context *ctx;
-	struct spu *tmp;
+	struct list_head *tmp;
 
 	mem_aff = gang->aff_ref_ctx->flags & SPU_CREATE_AFFINITY_MEM;
 	lowest_offset = 0;
 	gs = 0;
-	list_for_each_entry(tmp, &gang->aff_list_head, aff_list)
+	list_for_each(tmp, &gang->aff_list_head)
 		gs++;
 
 	list_for_each_entry_reverse(ctx, &gang->aff_ref_ctx->aff_list,
@@ -868,14 +868,14 @@ static struct spu* ctx_location(struct s
 		list_for_each_entry(spu, ref->aff_list.prev, aff_list) {
 			if (offset == 0)
 				break;
-			if (sched_spu(spu))
+			if (spu_is_schedulable(spu))
 				offset--;
 		}
 	} else {
 		list_for_each_entry_reverse(spu, ref->aff_list.next, aff_list) {
 			if (offset == 0)
 				break;
-			if (sched_spu(spu))
+			if (spu_is_schedulable(spu))
 				offset++;
 		}
 	}
Index: linux-2.6.21/arch/powerpc/platforms/cell/spufs/gang.c
===================================================================
--- linux-2.6.21.orig/arch/powerpc/platforms/cell/spufs/gang.c
+++ linux-2.6.21/arch/powerpc/platforms/cell/spufs/gang.c
@@ -38,6 +38,7 @@ struct spu_gang *alloc_spu_gang(void)
 	mutex_init(&gang->aff_mutex);
 	INIT_LIST_HEAD(&gang->list);
 	INIT_LIST_HEAD(&gang->aff_list_head);
+	gang->aff_sched_count = (atomic_t)ATOMIC_INIT(0);
 
 out:
 	return gang;



More information about the cbe-oss-dev mailing list