From patchwork Wed Dec 10 19:03:35 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Detsch X-Patchwork-Id: 13292 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id D793BDDF9E for ; Thu, 11 Dec 2008 06:16:17 +1100 (EST) X-Original-To: cbe-oss-dev@ozlabs.org Delivered-To: cbe-oss-dev@ozlabs.org Received: from igw3.br.ibm.com (igw3.br.ibm.com [32.104.18.26]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "igw3.br.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 4A07147509 for ; Thu, 11 Dec 2008 06:03:41 +1100 (EST) Received: from d24relay01.br.ibm.com (unknown [9.8.31.16]) by igw3.br.ibm.com (Postfix) with ESMTP id 8D3253901F0 for ; Wed, 10 Dec 2008 17:00:06 -0200 (BRDT) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.18.232.46]) by d24relay01.br.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id mBAK39hl3797208 for ; Wed, 10 Dec 2008 17:03:09 -0300 Received: from d24av01.br.ibm.com (loopback [127.0.0.1]) by d24av01.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id mBAJ3ZG8013844 for ; Wed, 10 Dec 2008 17:03:35 -0200 Received: from [9.8.13.23] ([9.8.13.23]) by d24av01.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id mBAJ3ZV9013832 for ; Wed, 10 Dec 2008 17:03:35 -0200 Date: Wed, 10 Dec 2008 17:03:35 -0200 From: adetsch@br.ibm.com Message-Id: <200812101903.mBAJ3ZV9013832@d24av01.br.ibm.com> To: cbe-oss-dev@ozlabs.org Subject: [Cbe-oss-dev] (no subject) X-BeenThere: cbe-oss-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Discussion about Open Source Software for the Cell Broadband Engine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org From 50b95c096a29c513e5502bfb8ab351b9980ea0b1 Mon Sep 17 00:00:00 2001 In-Reply-To: <200812101654.05091.adetsch@br.ibm.com> References: <200812101654.05091.adetsch@br.ibm.com> From: Andre Detsch Date: Wed, 10 Dec 2008 17:03:35 -0200 Subject: [PATCH 12/18] powerpc/spufs: Concentrate scheduling attributes in gang structure MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200812101703.35776.adetsch@br.ibm.com> Remove spus_allowed, policy and prio attributes from SPU context. Use attributes from the gang instead. Signed-off-by: Andre Detsch --- arch/powerpc/platforms/cell/spufs/context.c | 1 - arch/powerpc/platforms/cell/spufs/file.c | 2 +- arch/powerpc/platforms/cell/spufs/gang.c | 14 +++++ arch/powerpc/platforms/cell/spufs/run.c | 10 +++- arch/powerpc/platforms/cell/spufs/sched.c | 73 +-------------------------- arch/powerpc/platforms/cell/spufs/spufs.h | 4 -- 6 files changed, 26 insertions(+), 78 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c index 11b9237..3bda369 100644 --- a/arch/powerpc/platforms/cell/spufs/context.c +++ b/arch/powerpc/platforms/cell/spufs/context.c @@ -102,7 +102,6 @@ struct spu_context *alloc_spu_context(struct spu_gang *gang) ctx->owner = get_task_mm(current); INIT_LIST_HEAD(&ctx->aff_list); spu_gang_add_ctx(gang, ctx); - spu_update_sched_info(ctx); spu_set_timeslice(ctx); ctx->stats.util_state = SPU_UTIL_IDLE_LOADED; diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c index a02ee25..dbd1058 100644 --- a/arch/powerpc/platforms/cell/spufs/file.c +++ b/arch/powerpc/platforms/cell/spufs/file.c @@ -2646,7 +2646,7 @@ static int spufs_show_ctx(struct seq_file *s, void *private) ctx->state == SPU_STATE_SAVED ? 'S' : 'R', ctx->flags, ctx->sched_flags, - ctx->prio, + ctx->gang->prio, ctx->time_slice, ctx->spu ? ctx->spu->number : -1, !list_empty(&ctx->gang->rq) ? 'q' : ' ', diff --git a/arch/powerpc/platforms/cell/spufs/gang.c b/arch/powerpc/platforms/cell/spufs/gang.c index c64d0ad..7b1513d 100644 --- a/arch/powerpc/platforms/cell/spufs/gang.c +++ b/arch/powerpc/platforms/cell/spufs/gang.c @@ -43,11 +43,25 @@ struct spu_gang *alloc_spu_gang(void) /* * Inherit scheduling parameters from the creator of the gang. */ + + /* + * We do our own priority calculations, so we normally want + * ->static_prio to start with. Unfortunately this field + * contains junk for threads with a realtime scheduling + * policy so we have to look at ->prio in this case. + */ if (rt_prio(current->prio)) gang->prio = current->prio; else gang->prio = current->static_prio; + gang->policy = current->policy; + + /* + * TO DO: NUMA gang scheduling. The placement of the gang onto spus + * is based on the value of the cpus_allowed field of the thread + * that created the gang. It should be dynamic too. eww. + */ gang->cpus_allowed = current->cpus_allowed; out: diff --git a/arch/powerpc/platforms/cell/spufs/run.c b/arch/powerpc/platforms/cell/spufs/run.c index cbce273..b351230 100644 --- a/arch/powerpc/platforms/cell/spufs/run.c +++ b/arch/powerpc/platforms/cell/spufs/run.c @@ -409,7 +409,15 @@ long spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *event) spu_enable_spu(ctx); - spu_update_sched_info(ctx); + /* + * 32-Bit assignments are atomic on powerpc, and we don't care about + * memory ordering here because retrieving the controlling thread is + * per definition racy. + */ + ctx->tid = current->pid; + + /* Save the current cpu id for spu interrupt routing. */ + ctx->last_ran = raw_smp_processor_id(); ret = spu_run_init(ctx, npc); if (ret) { diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c index 5289cdb..be13b19 100644 --- a/arch/powerpc/platforms/cell/spufs/sched.c +++ b/arch/powerpc/platforms/cell/spufs/sched.c @@ -143,75 +143,6 @@ void spu_set_timeslice(struct spu_context *ctx) ctx->time_slice = SCALE_PRIO(DEF_SPU_TIMESLICE, gang->prio); } -/* - * Update scheduling information from the owning thread. - */ -static void __spu_update_sched_info(struct spu_context *ctx) -{ - /* - * 32-Bit assignments are atomic on powerpc, and we don't care about - * memory ordering here because retrieving the controlling thread is - * per definition racy. - */ - ctx->tid = current->pid; - - /* - * We do our own priority calculations, so we normally want - * ->static_prio to start with. Unfortunately this field - * contains junk for threads with a realtime scheduling - * policy so we have to look at ->prio in this case. - */ - if (rt_prio(current->prio)) - ctx->prio = current->prio; - else - ctx->prio = current->static_prio; - ctx->policy = current->policy; - - /* - * TO DO: effective gang priorities. Currently, the gang's priority - * is inherited from the thread that allocates the gang structure. - * Therefore, it never changes. It should be based on the dynamic - * value of the controlling threads. - */ - - /* - * TO DO: the context may be loaded, so we may need to activate - * it again on a different node. But it shouldn't hurt anything - * to update its parameters, because we know that the scheduler - * is not actively looking at this field, since it is not on the - * runqueue. The context will be rescheduled on the proper node - * if it is timesliced or preempted. - */ - ctx->cpus_allowed = current->cpus_allowed; - - /* - * TO DO: NUMA gang scheduling. The placement of the gang onto spus - * is based on the value of the cpus_allowed field of the thread - * that created the gang. It should be dynamic too. eww. - */ - - /* Save the current cpu id for spu interrupt routing. */ - ctx->last_ran = raw_smp_processor_id(); -} - -void spu_update_sched_info(struct spu_context *ctx) -{ - int node; - - if (ctx->state == SPU_STATE_RUNNABLE) { - node = ctx->spu->node; - - /* - * Take list_mutex to sync with find_victim(). - */ - mutex_lock(&cbe_spu_info[node].list_mutex); - __spu_update_sched_info(ctx); - mutex_unlock(&cbe_spu_info[node].list_mutex); - } else { - __spu_update_sched_info(ctx); - } -} - static int __node_allowed(struct spu_gang *gang, int node) { if (nr_cpus_node(node)) { @@ -1246,7 +1177,7 @@ static noinline int spusched_tick(struct spu_gang *gang, */ yield = atomic_read(&gang->nrunnable) == atomic_read(&gang->nfaulting); - if (yield || ((ctx->policy != SCHED_FIFO) && (!--ctx->time_slice))) { + if (yield || ((gang->policy != SCHED_FIFO) && (!--ctx->time_slice))) { if (spu_prio->nr_waiting) { best = find_first_bit(spu_prio->bitmap, gang->prio); if (yield || (preempt && best <= gang->prio)) { @@ -1259,7 +1190,7 @@ static noinline int spusched_tick(struct spu_gang *gang, } } spu_context_nospu_trace(spusched_tick__newslice, ctx); - if (ctx->policy != SCHED_FIFO) + if (gang->policy != SCHED_FIFO) ctx->time_slice++; } out: diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h index 468ee37..bfe4098 100644 --- a/arch/powerpc/platforms/cell/spufs/spufs.h +++ b/arch/powerpc/platforms/cell/spufs/spufs.h @@ -124,9 +124,6 @@ struct spu_context { /* scheduler fields */ unsigned int time_slice; unsigned long sched_flags; - cpumask_t cpus_allowed; - int policy; - int prio; int last_ran; /* statistics */ @@ -343,7 +340,6 @@ void spu_switch_notify(struct spu *spu, struct spu_context *ctx); void spu_switch_log_notify(struct spu *spu, struct spu_context *ctx, u32 type, u32 val); void spu_set_timeslice(struct spu_context *ctx); -void spu_update_sched_info(struct spu_context *ctx); int __init spu_sched_init(void); void spu_sched_exit(void);