diff options
Diffstat (limited to 'arch/powerpc/platforms/cell/spufs/sched.c')
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/sched.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c index 9fc09306c9ae..bb16c22360d5 100644 --- a/arch/powerpc/platforms/cell/spufs/sched.c +++ b/arch/powerpc/platforms/cell/spufs/sched.c | |||
@@ -229,6 +229,10 @@ static void spu_bind_context(struct spu *spu, struct spu_context *ctx) | |||
229 | { | 229 | { |
230 | pr_debug("%s: pid=%d SPU=%d NODE=%d\n", __FUNCTION__, current->pid, | 230 | pr_debug("%s: pid=%d SPU=%d NODE=%d\n", __FUNCTION__, current->pid, |
231 | spu->number, spu->node); | 231 | spu->number, spu->node); |
232 | |||
233 | ctx->stats.slb_flt_base = spu->stats.slb_flt; | ||
234 | ctx->stats.class2_intr_base = spu->stats.class2_intr; | ||
235 | |||
232 | spu->ctx = ctx; | 236 | spu->ctx = ctx; |
233 | spu->flags = 0; | 237 | spu->flags = 0; |
234 | ctx->spu = spu; | 238 | ctx->spu = spu; |
@@ -275,6 +279,11 @@ static void spu_unbind_context(struct spu *spu, struct spu_context *ctx) | |||
275 | ctx->spu = NULL; | 279 | ctx->spu = NULL; |
276 | spu->flags = 0; | 280 | spu->flags = 0; |
277 | spu->ctx = NULL; | 281 | spu->ctx = NULL; |
282 | |||
283 | ctx->stats.slb_flt += | ||
284 | (spu->stats.slb_flt - ctx->stats.slb_flt_base); | ||
285 | ctx->stats.class2_intr += | ||
286 | (spu->stats.class2_intr - ctx->stats.class2_intr_base); | ||
278 | } | 287 | } |
279 | 288 | ||
280 | /** | 289 | /** |
@@ -400,6 +409,7 @@ static struct spu *find_victim(struct spu_context *ctx) | |||
400 | } | 409 | } |
401 | spu_remove_from_active_list(spu); | 410 | spu_remove_from_active_list(spu); |
402 | spu_unbind_context(spu, victim); | 411 | spu_unbind_context(spu, victim); |
412 | victim->stats.invol_ctx_switch++; | ||
403 | mutex_unlock(&victim->state_mutex); | 413 | mutex_unlock(&victim->state_mutex); |
404 | /* | 414 | /* |
405 | * We need to break out of the wait loop in spu_run | 415 | * We need to break out of the wait loop in spu_run |
@@ -425,6 +435,7 @@ static struct spu *find_victim(struct spu_context *ctx) | |||
425 | */ | 435 | */ |
426 | int spu_activate(struct spu_context *ctx, unsigned long flags) | 436 | int spu_activate(struct spu_context *ctx, unsigned long flags) |
427 | { | 437 | { |
438 | spuctx_switch_state(ctx, SPUCTX_UTIL_SYSTEM); | ||
428 | 439 | ||
429 | if (ctx->spu) | 440 | if (ctx->spu) |
430 | return 0; | 441 | return 0; |
@@ -492,6 +503,7 @@ static int __spu_deactivate(struct spu_context *ctx, int force, int max_prio) | |||
492 | if (new || force) { | 503 | if (new || force) { |
493 | spu_remove_from_active_list(spu); | 504 | spu_remove_from_active_list(spu); |
494 | spu_unbind_context(spu, ctx); | 505 | spu_unbind_context(spu, ctx); |
506 | ctx->stats.vol_ctx_switch++; | ||
495 | spu_free(spu); | 507 | spu_free(spu); |
496 | if (new) | 508 | if (new) |
497 | wake_up(&new->stop_wq); | 509 | wake_up(&new->stop_wq); |
@@ -521,6 +533,7 @@ void spu_deactivate(struct spu_context *ctx) | |||
521 | } | 533 | } |
522 | 534 | ||
523 | __spu_deactivate(ctx, 1, MAX_PRIO); | 535 | __spu_deactivate(ctx, 1, MAX_PRIO); |
536 | spuctx_switch_state(ctx, SPUCTX_UTIL_USER); | ||
524 | } | 537 | } |
525 | 538 | ||
526 | /** | 539 | /** |
@@ -535,7 +548,10 @@ void spu_yield(struct spu_context *ctx) | |||
535 | { | 548 | { |
536 | if (!(ctx->flags & SPU_CREATE_NOSCHED)) { | 549 | if (!(ctx->flags & SPU_CREATE_NOSCHED)) { |
537 | mutex_lock(&ctx->state_mutex); | 550 | mutex_lock(&ctx->state_mutex); |
538 | __spu_deactivate(ctx, 0, MAX_PRIO); | 551 | if (__spu_deactivate(ctx, 0, MAX_PRIO)) |
552 | spuctx_switch_state(ctx, SPUCTX_UTIL_USER); | ||
553 | else | ||
554 | spuctx_switch_state(ctx, SPUCTX_UTIL_LOADED); | ||
539 | mutex_unlock(&ctx->state_mutex); | 555 | mutex_unlock(&ctx->state_mutex); |
540 | } | 556 | } |
541 | } | 557 | } |
@@ -564,6 +580,7 @@ static void spusched_tick(struct spu_context *ctx) | |||
564 | 580 | ||
565 | __spu_remove_from_active_list(spu); | 581 | __spu_remove_from_active_list(spu); |
566 | spu_unbind_context(spu, ctx); | 582 | spu_unbind_context(spu, ctx); |
583 | ctx->stats.invol_ctx_switch++; | ||
567 | spu_free(spu); | 584 | spu_free(spu); |
568 | wake_up(&new->stop_wq); | 585 | wake_up(&new->stop_wq); |
569 | /* | 586 | /* |