From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161162AbWGNBWE (ORCPT ); Thu, 13 Jul 2006 21:22:04 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1161163AbWGNBWE (ORCPT ); Thu, 13 Jul 2006 21:22:04 -0400 Received: from smtp.osdl.org ([65.172.181.4]:3227 "EHLO smtp.osdl.org") by vger.kernel.org with ESMTP id S1161162AbWGNBWC (ORCPT ); Thu, 13 Jul 2006 21:22:02 -0400 Date: Thu, 13 Jul 2006 18:18:35 -0700 From: Andrew Morton To: Roland Dreier Cc: arjan@infradead.org, mingo@elte.hu, zach.brown@oracle.com, openib-general@openib.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Convert idr's internal locking to _irqsave variant Message-Id: <20060713181835.ad5eeff6.akpm@osdl.org> In-Reply-To: References: <44B405C8.4040706@oracle.com> <44B433CE.1030103@oracle.com> <20060712093820.GA9218@elte.hu> <20060712183049.bcb6c404.akpm@osdl.org> <20060713135446.5e2c6dd5.akpm@osdl.org> <20060713144341.97d4f771.akpm@osdl.org> X-Mailer: Sylpheed version 2.2.4 (GTK+ 2.8.17; i686-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 X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 13 Jul 2006 18:08:17 -0700 Roland Dreier wrote: > > Good point, a try-again loop would work. Do we really need the caller to > > maintain a cache? I suspect something like > > > > drat: > > if (idr_pre_get(GFP_KERNEL) == ENOMEM) > > give_up(); > > spin_lock(); > > ret = idr_get_new(); > > spin_unlock(); > > if (ret == ENOMEM) > > goto drat; > > > > would do it. > > The problem (for my tiny brain at least) is that I don't know where > idr_pre_get() can put the memory it allocates if there's no lock in > the idr structure -- how do you maintain internal consistency if no > locks are held when filling the cache? argh. Aren't you supposed to be on vacation or something? > Having the caller hold a chunk of memory in a stack variable was the > trick I came up with to get around that. Yes, that certainly works.