Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 48255
b: refs/heads/master
c: 2eb1b12
h: refs/heads/master
i:
  48253: 9ada1ae
  48251: 93a03c3
  48247: 985eff0
  48239: dd6698e
  48223: c8128c0
  48191: b1ea864
  48127: 80eb318
v: v3
  • Loading branch information
Christoph Hellwig authored and Arnd Bergmann committed Feb 13, 2007
1 parent 36b3778 commit 1eecad7
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 72cb360839f88c02ccf38f1df214316e05886ff3
refs/heads/master: 2eb1b12049844a8ebc670e0e4fc908bc3f8933d3
2 changes: 2 additions & 0 deletions trunk/arch/powerpc/platforms/cell/spufs/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ struct spu_context *alloc_spu_context(struct spu_gang *gang)
if (gang)
spu_gang_add_ctx(gang, ctx);
ctx->rt_priority = current->rt_priority;
ctx->policy = current->policy;
ctx->prio = current->prio;
INIT_DELAYED_WORK(&ctx->sched_work, spu_sched_tick);
goto out;
out_free:
kfree(ctx);
Expand Down
9 changes: 7 additions & 2 deletions trunk/arch/powerpc/platforms/cell/spufs/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ static inline int spu_run_init(struct spu_context *ctx, u32 * npc)
(SPU_RUNCNTL_RUNNABLE | SPU_RUNCNTL_ISOLATE);
if (runcntl == 0)
runcntl = SPU_RUNCNTL_RUNNABLE;
} else
} else {
spu_start_tick(ctx);
ctx->ops->npc_write(ctx, *npc);
}

ctx->ops->runcntl_write(ctx, runcntl);
return ret;
Expand All @@ -176,6 +178,7 @@ static inline int spu_run_fini(struct spu_context *ctx, u32 * npc,
{
int ret = 0;

spu_stop_tick(ctx);
*status = ctx->ops->status_read(ctx);
*npc = ctx->ops->npc_read(ctx);
spu_release(ctx);
Expand Down Expand Up @@ -329,8 +332,10 @@ long spufs_run_spu(struct file *file, struct spu_context *ctx,
}
if (unlikely(ctx->state != SPU_STATE_RUNNABLE)) {
ret = spu_reacquire_runnable(ctx, npc, &status);
if (ret)
if (ret) {
spu_stop_tick(ctx);
goto out2;
}
continue;
}
ret = spu_process_events(ctx);
Expand Down
43 changes: 42 additions & 1 deletion trunk/arch/powerpc/platforms/cell/spufs/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include <asm/spu_priv1.h>
#include "spufs.h"

#define SPU_MIN_TIMESLICE (100 * HZ / 1000)
#define SPU_TIMESLICE (HZ)

struct spu_prio_array {
DECLARE_BITMAP(bitmap, MAX_PRIO);
Expand All @@ -55,6 +55,7 @@ struct spu_prio_array {
};

static struct spu_prio_array *spu_prio;
static struct workqueue_struct *spu_sched_wq;

static inline int node_allowed(int node)
{
Expand All @@ -68,6 +69,40 @@ static inline int node_allowed(int node)
return 1;
}

void spu_start_tick(struct spu_context *ctx)
{
if (ctx->policy == SCHED_RR)
queue_delayed_work(spu_sched_wq, &ctx->sched_work, SPU_TIMESLICE);
}

void spu_stop_tick(struct spu_context *ctx)
{
if (ctx->policy == SCHED_RR)
cancel_delayed_work(&ctx->sched_work);
}

void spu_sched_tick(struct work_struct *work)
{
struct spu_context *ctx =
container_of(work, struct spu_context, sched_work.work);
struct spu *spu;
int rearm = 1;

mutex_lock(&ctx->state_mutex);
spu = ctx->spu;
if (spu) {
int best = sched_find_first_bit(spu_prio->bitmap);
if (best <= ctx->prio) {
spu_deactivate(ctx);
rearm = 0;
}
}
mutex_unlock(&ctx->state_mutex);

if (rearm)
spu_start_tick(ctx);
}

/**
* spu_add_to_active_list - add spu to active list
* @spu: spu to add to the active list
Expand Down Expand Up @@ -437,10 +472,15 @@ int __init spu_sched_init(void)
{
int i;

spu_sched_wq = create_singlethread_workqueue("spusched");
if (!spu_sched_wq)
return 1;

spu_prio = kzalloc(sizeof(struct spu_prio_array), GFP_KERNEL);
if (!spu_prio) {
printk(KERN_WARNING "%s: Unable to allocate priority queue.\n",
__FUNCTION__);
destroy_workqueue(spu_sched_wq);
return 1;
}
for (i = 0; i < MAX_PRIO; i++) {
Expand Down Expand Up @@ -471,4 +511,5 @@ void __exit spu_sched_exit(void)
mutex_unlock(&spu_prio->active_mutex[node]);
}
kfree(spu_prio);
destroy_workqueue(spu_sched_wq);
}
5 changes: 5 additions & 0 deletions trunk/arch/powerpc/platforms/cell/spufs/spufs.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ struct spu_context {

/* scheduler fields */
struct list_head rq;
struct delayed_work sched_work;
unsigned long sched_flags;
unsigned long rt_priority;
int policy;
int prio;
};

Expand Down Expand Up @@ -195,6 +197,9 @@ enum {
int spu_activate(struct spu_context *ctx, unsigned long flags);
void spu_deactivate(struct spu_context *ctx);
void spu_yield(struct spu_context *ctx);
void spu_start_tick(struct spu_context *ctx);
void spu_stop_tick(struct spu_context *ctx);
void spu_sched_tick(struct work_struct *work);
int __init spu_sched_init(void);
void __exit spu_sched_exit(void);

Expand Down

0 comments on commit 1eecad7

Please sign in to comment.