From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932487AbWGMBeS (ORCPT ); Wed, 12 Jul 2006 21:34:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932488AbWGMBeS (ORCPT ); Wed, 12 Jul 2006 21:34:18 -0400 Received: from smtp.osdl.org ([65.172.181.4]:55740 "EHLO smtp.osdl.org") by vger.kernel.org with ESMTP id S932487AbWGMBeR (ORCPT ); Wed, 12 Jul 2006 21:34:17 -0400 Date: Wed, 12 Jul 2006 18:30:49 -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: <20060712183049.bcb6c404.akpm@osdl.org> In-Reply-To: References: <44B405C8.4040706@oracle.com> <44B433CE.1030103@oracle.com> <20060712093820.GA9218@elte.hu> 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 Wed, 12 Jul 2006 13:45:12 -0700 Roland Dreier wrote: > Currently, the code in lib/idr.c uses a bare spin_lock(&idp->lock) to > do internal locking. This is a nasty trap for code that might call > idr functions from different contexts; for example, it seems perfectly > reasonable to call idr_get_new() from process context and idr_remove() > from interrupt context -- but with the current locking this would lead > to a potential deadlock. > > The simplest fix for this is to just convert the idr locking to use > spin_lock_irqsave(). > > In particular, this fixes a very complicated locking issue detected by > lockdep, involving the ib_ipoib driver's priv->lock and dev->_xmit_lock, > which get involved with the ib_sa module's query_idr.lock. Sigh. It was always a mistake (of the kernel programming 101 type) to put any locking at all in the idr code. At some stage we need to weed it all out and move it to callers. Your fix is yet more fallout from that mistake.