aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorAndre Detsch <adetsch@br.ibm.com>2008-10-20 20:15:23 -0400
committerJeremy Kerr <jk@ozlabs.org>2008-10-20 20:15:23 -0400
commit10baa26c8ccba6f100397c9ba6534be175762e8d (patch)
treea909c5246f40932848858c8ed72894fd58732fb1 /arch/powerpc
parent837ef884b702edd1c4514eaed1dbecd48721bd22 (diff)
powerpc/spufs: Improve search of node for contexts with SPU affinity
This patch improves redability of the code responsible for trying to find a node with enough SPUs not committed to other affinity gangs. An additional check is also added, to avoid taking into account gangs that have no SPU affinity. Signed-off-by: Andre Detsch <adetsch@br.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/platforms/cell/spufs/sched.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 67595bc380dc..6253df5a436e 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -312,6 +312,15 @@ static struct spu *aff_ref_location(struct spu_context *ctx, int mem_aff,
312 */ 312 */
313 node = cpu_to_node(raw_smp_processor_id()); 313 node = cpu_to_node(raw_smp_processor_id());
314 for (n = 0; n < MAX_NUMNODES; n++, node++) { 314 for (n = 0; n < MAX_NUMNODES; n++, node++) {
315 /*
316 * "available_spus" counts how many spus are not potentially
317 * going to be used by other affinity gangs whose reference
318 * context is already in place. Although this code seeks to
319 * avoid having affinity gangs with a summed amount of
320 * contexts bigger than the amount of spus in the node,
321 * this may happen sporadically. In this case, available_spus
322 * becomes negative, which is harmless.
323 */
315 int available_spus; 324 int available_spus;
316 325
317 node = (node < MAX_NUMNODES) ? node : 0; 326 node = (node < MAX_NUMNODES) ? node : 0;
@@ -321,12 +330,10 @@ static struct spu *aff_ref_location(struct spu_context *ctx, int mem_aff,
321 available_spus = 0; 330 available_spus = 0;
322 mutex_lock(&cbe_spu_info[node].list_mutex); 331 mutex_lock(&cbe_spu_info[node].list_mutex);
323 list_for_each_entry(spu, &cbe_spu_info[node].spus, cbe_list) { 332 list_for_each_entry(spu, &cbe_spu_info[node].spus, cbe_list) {
324 if (spu->ctx && spu->ctx->gang 333 if (spu->ctx && spu->ctx->gang && !spu->ctx->aff_offset
325 && spu->ctx->aff_offset == 0) 334 && spu->ctx->gang->aff_ref_spu)
326 available_spus -= 335 available_spus -= spu->ctx->gang->contexts;
327 (spu->ctx->gang->contexts - 1); 336 available_spus++;
328 else
329 available_spus++;
330 } 337 }
331 if (available_spus < ctx->gang->contexts) { 338 if (available_spus < ctx->gang->contexts) {
332 mutex_unlock(&cbe_spu_info[node].list_mutex); 339 mutex_unlock(&cbe_spu_info[node].list_mutex);