Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932513AbZLDWiV (ORCPT ); Fri, 4 Dec 2009 17:38:21 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752172AbZLDWiV (ORCPT ); Fri, 4 Dec 2009 17:38:21 -0500 Received: from smtp1.linux-foundation.org ([140.211.169.13]:46321 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751640AbZLDWiU (ORCPT ); Fri, 4 Dec 2009 17:38:20 -0500 Date: Fri, 4 Dec 2009 14:38:02 -0800 From: Andrew Morton To: =?ISO-8859-1?Q?Andr=E9?= Goddard Rosa Cc: "linux list" , Pekka Enberg Subject: Re: [PATCH 1/2][resend] pid: tighten pidmap spinlock critical section by removing kfree() Message-Id: <20091204143802.17f3fded.akpm@linux-foundation.org> In-Reply-To: <0e91f1c4ecc5bc5000f729ccb56e9b6e1fbd4bd3.1258805412.git.andre.goddard@gmail.com> References: <0e91f1c4ecc5bc5000f729ccb56e9b6e1fbd4bd3.1258805412.git.andre.goddard@gmail.com> X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.9; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1309 Lines: 43 On Thu, 3 Dec 2009 12:53:37 -0200 Andr__ Goddard Rosa wrote: > Avoid calling kfree() under pidmap spinlock, calling it afterwards. > > Normally kfree() is fast, but sometimes it can be slow, so avoid > calling it under the spinlock if we can do it. > > Signed-off-by: Andr__ Goddard Rosa > cc: Pekka Enberg > --- > kernel/pid.c | 7 ++++--- > 1 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/kernel/pid.c b/kernel/pid.c > index d3f722d..55fd590 100644 > --- a/kernel/pid.c > +++ b/kernel/pid.c > @@ -141,11 +141,12 @@ static int alloc_pidmap(struct pid_namespace *pid_ns) > * installing it: > */ > spin_lock_irq(&pidmap_lock); > - if (map->page) > - kfree(page); > - else > + if (!map->page) { > map->page = page; > + page = NULL; > + } > spin_unlock_irq(&pidmap_lock); > + kfree(page); > if (unlikely(!map->page)) > break; > } um, OK, but the chances of that kfree() actually being executed are very small. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/