From patchwork Wed Dec 10 19:03:38 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Detsch X-Patchwork-Id: 13293 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 158A1DDF9C for ; Thu, 11 Dec 2008 06:17:51 +1100 (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 "igw2.br.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 70038474CB for ; Thu, 11 Dec 2008 06:03:50 +1100 (EST) Received: from d24relay01.br.ibm.com (unknown [9.8.31.16]) by igw2.br.ibm.com (Postfix) with ESMTP id 9FDAA17F6EF for ; Wed, 10 Dec 2008 15:46:50 -0200 (BRDT) Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.18.232.47]) by d24relay01.br.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id mBAK3DNr3547244 for ; Wed, 10 Dec 2008 17:03:13 -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 mBAJ3dQ9022823 for ; Wed, 10 Dec 2008 17:03:39 -0200 Received: from [9.8.13.23] ([9.8.13.23]) by d24av02.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id mBAJ3chG022791 for ; Wed, 10 Dec 2008 17:03:38 -0200 Date: Wed, 10 Dec 2008 17:03:38 -0200 From: adetsch@br.ibm.com Message-Id: <200812101903.mBAJ3chG022791@d24av02.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 3b992bb08fb4a5506446a2347fa0f28170c0a60c 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:39 -0200 Subject: [PATCH 13/18] powerpc/spufs: Fix memory leak on implicit gangs MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200812101703.39179.adetsch@br.ibm.com> If the context has no explicit gang, there is no spufs gang directory, whose deletion would lead to a put_spu_context. So, we need to perform a put_spu_context operation after the context was allocated, or else the gang would never be freeded. Signed-off-by: Andre Detsch --- arch/powerpc/platforms/cell/spufs/context.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) /* Binding to physical processor deferred @@ -107,6 +111,15 @@ struct spu_context *alloc_spu_context(struct spu_gang *gang) atomic_inc(&nr_spu_contexts); + /* + * If the context has no explicit gang, there is no spufs gang + * directory, whose deletion would lead to a put_spu_context. + * So, we do the put here, or else the gang would never be + * freeded. + */ + if (!has_gang) + put_spu_gang(gang); + goto out; out_free_gang: diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c index 3bda369..0e37eff 100644 --- a/arch/powerpc/platforms/cell/spufs/context.c +++ b/arch/powerpc/platforms/cell/spufs/context.c @@ -51,6 +51,7 @@ static void dec_active_gangs(struct spu_gang *gang) struct spu_context *alloc_spu_context(struct spu_gang *gang) { struct spu_context *ctx; + int has_gang; ctx = kzalloc(sizeof *ctx, GFP_KERNEL); if (!ctx) @@ -62,9 +63,12 @@ struct spu_context *alloc_spu_context(struct spu_gang *gang) * the gang is a gang of one. */ if (!gang) { + has_gang = 0; gang = alloc_spu_gang(); if (!gang) goto out_free; + } else { + has_gang = 1; }