[POWERPC] spusched: Fix initial timeslice calculation

Currently we calculate the first timeslice for every context
incorrectly - alloc_spu_context calls spu_set_timeslice before we set
ctx->prio so we always calculate the longest possible timeslice for the
lowest possible priority.

This patch makes sure to update the schedule-related fields before
calculating the timeslice and also makes sure we update the timeslice for
a non-running context when entering spu_run so a priority change affects
the context as soon as possible.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
Christoph Hellwig 2007-07-25 21:31:09 +10:00 committed by Paul Mackerras
parent 6f6a6dc0c8
commit 9d78592ed7
2 changed files with 6 additions and 1 deletions

View File

@ -59,7 +59,8 @@ struct spu_context *alloc_spu_context(struct spu_gang *gang)
INIT_LIST_HEAD(&ctx->aff_list); INIT_LIST_HEAD(&ctx->aff_list);
if (gang) if (gang)
spu_gang_add_ctx(gang, ctx); spu_gang_add_ctx(gang, ctx);
ctx->cpus_allowed = current->cpus_allowed;
__spu_update_sched_info(ctx);
spu_set_timeslice(ctx); spu_set_timeslice(ctx);
ctx->stats.util_state = SPU_UTIL_IDLE_LOADED; ctx->stats.util_state = SPU_UTIL_IDLE_LOADED;

View File

@ -312,6 +312,7 @@ long spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *event)
spu_acquire(ctx); spu_acquire(ctx);
if (ctx->state == SPU_STATE_SAVED) { if (ctx->state == SPU_STATE_SAVED) {
__spu_update_sched_info(ctx); __spu_update_sched_info(ctx);
spu_set_timeslice(ctx);
ret = spu_activate(ctx, 0); ret = spu_activate(ctx, 0);
if (ret) { if (ret) {
@ -322,6 +323,9 @@ long spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *event)
/* /*
* We have to update the scheduling priority under active_mutex * We have to update the scheduling priority under active_mutex
* to protect against find_victim(). * to protect against find_victim().
*
* No need to update the timeslice ASAP, it will get updated
* once the current one has expired.
*/ */
spu_update_sched_info(ctx); spu_update_sched_info(ctx);
} }