[Cbe-oss-dev] [PATCH 3/3] spu sched: forced preemption at execution

Luke Browning LukeBrowning at us.ibm.com
Fri Feb 23 12:11:38 EST 2007







cbe-oss-dev-bounces+lukebrowning=us.ibm.com at ozlabs.org wrote on 02/09/2007
01:47:29 PM:

> On Fri, Feb 09, 2007 at 12:43:01AM +0100, Christoph Hellwig wrote:
> > If we start a spu context with realtime priority we want it to run
> > immediately and not wait until some other lower priority thread has
> > finished.  Try to find a suitable victim and use it's spu in this
> > case.
>
> Due to a mistake in my quilt usage this is missing the changes to
> context.c and spufs.h.  The full patch is below:
>
> Index: linux-2.6/arch/powerpc/platforms/cell/spufs/sched.c
> ===================================================================
> --- linux-2.6.orig/arch/powerpc/platforms/cell/spufs/sched.c
> 2007-02-09 16:08:51.000000000 +0100
> +++ linux-2.6/arch/powerpc/platforms/cell/spufs/sched.c   2007-02-09
> 16:08:57.000000000 +0100
> @@ -282,6 +282,74 @@
>  }
>
>  /**
> + * find_victim - find a lower priority context to preempt
> + * @ctx:   canidate context for running
> + *
> + * Returns the freed physical spu to run the new context on.
> + */
> +static struct spu *find_victim(struct spu_context *ctx)
> +{
> +   struct spu_context *victim = NULL;
> +   struct spu *spu;
> +   int node, n;
> +
> +   /*
> +    * Look for a possible preemption candidate on the local node first.
> +    * If there is no candidate look at the other nodes.  This isn't
> +    * exactly fair, but so far the whole spu schedule tries to keep
> +    * a strong node affinity.  We might want to fine-tune this in
> +    * the future.
> +    */
> + restart:
> +   node = cpu_to_node(raw_smp_processor_id());
> +   for (n = 0; n < MAX_NUMNODES; n++, node++) {
> +      node = (node < MAX_NUMNODES) ? node : 0;
> +      if (!node_allowed(node))
> +         continue;
> +
> +      mutex_lock(&spu_prio->active_mutex[node]);
> +      list_for_each_entry(spu, &spu_prio->active_list[node], list) {
> +         struct spu_context *tmp = spu->ctx;
> +
> +         if (tmp->rt_priority < ctx->rt_priority &&
> +             (!victim || tmp->rt_priority < victim->rt_priority))
> +            victim = spu->ctx;
> +      }


You really want to preempt sched_other jobs before fixed priority jobs.
Does the
above consider sched_other jobs.   what is the relationship between prio
and rt_priority?

Luke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/cbe-oss-dev/attachments/20070222/1d5a8df9/attachment.htm>


More information about the cbe-oss-dev mailing list