From patchwork Thu Sep 11 23:38:11 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Detsch X-Patchwork-Id: 252 X-Patchwork-Delegate: jk@ozlabs.org Return-Path: X-Original-To: patchwork@ozlabs.org Delivered-To: patchwork@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 95519DE132 for ; Fri, 12 Sep 2008 09:39:50 +1000 (EST) X-Original-To: cbe-oss-dev@ozlabs.org Delivered-To: cbe-oss-dev@ozlabs.org Received: from igw2.br.ibm.com (igw2.br.ibm.com [32.104.18.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mailgw2.br.ibm.com", Issuer "Equifax" (not verified)) by ozlabs.org (Postfix) with ESMTPS id E5546DE007; Fri, 12 Sep 2008 09:38:59 +1000 (EST) Received: from mailhub1.br.ibm.com (mailhub1 [9.18.232.109]) by igw2.br.ibm.com (Postfix) with ESMTP id 78F1417F429; Thu, 11 Sep 2008 20:23:42 -0300 (BRT) Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.18.232.47]) by mailhub1.br.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id m8BNd0XX2183430; Thu, 11 Sep 2008 20:39:00 -0300 Received: from d24av02.br.ibm.com (loopback [127.0.0.1]) by d24av02.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m8BNcrYS030017; Thu, 11 Sep 2008 20:38:53 -0300 Received: from [9.8.10.86] ([9.8.10.86]) by d24av02.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m8BNcqVr030009; Thu, 11 Sep 2008 20:38:53 -0300 From: Andre Detsch To: cbe-oss-dev@ozlabs.org Date: Thu, 11 Sep 2008 20:38:11 -0300 User-Agent: KMail/1.9.6 References: <200809111955.28780.adetsch@br.ibm.com> In-Reply-To: <200809111955.28780.adetsch@br.ibm.com> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200809112038.11711.adetsch@br.ibm.com> Cc: LukeBrowning@us.ibm.com, Jeremy Kerr Subject: [Cbe-oss-dev] [PATCH 05/11] powerpc/spufs: Gang should yield its spu(s) on major page 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: , Sender: cbe-oss-dev-bounces+patchwork=ozlabs.org@ozlabs.org Errors-To: cbe-oss-dev-bounces+patchwork=ozlabs.org@ozlabs.org Implement gang level nfaulting count that is incremented and decremented across major page faults enabling the gang to be yielded when there are no runnable contexts in the gang. If there are no other runnable gangs waiting to be dispatched, then the gang remains lazily loaded. Otherwise, it is switched out and put on the rq. The nrunnable count is the number of contexts in the gang that are inside spu_run() and are considered runnable. Signed-off-by: Luke Browning Signed-off-by: Andre Detsch diff --git a/arch/powerpc/platforms/cell/spufs/fault.c b/arch/powerpc/platforms/cell/spufs/fault.c index f093a58..9e270b9 100644 --- a/arch/powerpc/platforms/cell/spufs/fault.c +++ b/arch/powerpc/platforms/cell/spufs/fault.c @@ -149,8 +149,16 @@ int spufs_handle_class1(struct spu_context *ctx) local_irq_restore(flags); /* hashing failed, so try the actual fault handler */ - if (ret) + if (ret) { + struct spu_gang *gang = ctx->gang; + + atomic_inc(&gang->nfaulting); + if (atomic_read(&gang->nrunnable) == + atomic_read(&gang->nfaulting)) + spu_yield(ctx); ret = spu_handle_mm_fault(current->mm, ea, dsisr, &flt); + atomic_dec(&gang->nfaulting); + } /* * This is nasty: we need the state_mutex for all the bookkeeping even @@ -166,8 +174,7 @@ int spufs_handle_class1(struct spu_context *ctx) ctx->csa.class_1_dar = ctx->csa.class_1_dsisr = 0; /* - * If we handled the fault successfully and are in runnable - * state, restart the DMA. + * If we handled the fault successfully, restart the DMA. * In case of unhandled error report the problem to user space. */ if (!ret) { diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h index f7d3e96..bc3b499 100644 --- a/arch/powerpc/platforms/cell/spufs/spufs.h +++ b/arch/powerpc/platforms/cell/spufs/spufs.h @@ -168,6 +168,7 @@ struct spu_gang { int prio; atomic_t nstarted; atomic_t nrunnable; + atomic_t nfaulting; unsigned long sched_flags; struct list_head rq;