Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753923Ab2FZTBm (ORCPT ); Tue, 26 Jun 2012 15:01:42 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:43610 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751026Ab2FZTBl (ORCPT ); Tue, 26 Jun 2012 15:01:41 -0400 MIME-Version: 1.0 In-Reply-To: <1340736849-14875-2-git-send-email-yinghai@kernel.org> References: <1340736849-14875-1-git-send-email-yinghai@kernel.org> <1340736849-14875-2-git-send-email-yinghai@kernel.org> From: Linus Torvalds Date: Tue, 26 Jun 2012 12:01:19 -0700 X-Google-Sender-Auth: -RsGbQYldX1B_hgQRNmrv_hT9HI Message-ID: Subject: Re: [PATCH -v12 01/15] resources: Split out __allocate_resource() To: Yinghai Lu Cc: Bjorn Helgaas , Benjamin Herrenschmidt , Tony Luck , David Miller , x86 , Dominik Brodowski , Andrew Morton , Greg Kroah-Hartman , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1021 Lines: 25 On Tue, Jun 26, 2012 at 11:53 AM, Yinghai Lu wrote: > It will take bool lock, so we could use it in other functions that > hold the resource lock already. This is too damn ugly. These kinds of "conditionally take lock" things are always just bugs waiting to happen. Don't do it. Just make the rule be that the caller of the __allocate_resource helper has to hold the lock. Sure, that means that you need to then use split reallocate_resource() into a helper function (ie a static __reallocate_resource() that needs to have the lock taken by the caller too), but dammit, that's definitely the right thing to do anyway. These kinds of "bool lock" crap things have to die. They are *wrong*. They are a sign of bad locking rules. Linus -- 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/