From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Gleixner Subject: Re: [PATCH 11/18] fs: Introduce per-bucket inode hash locks Date: Sun, 24 Oct 2010 17:44:24 +0200 (CEST) Message-ID: References: <1286515292-15882-12-git-send-email-david@fromorbit.com> <20101008185409.GA29251@infradead.org> <20101016075703.GO19147@amd> <20101016161642.GC16861@infradead.org> <20101016171213.GC3240@amd> <20101017004610.GB29677@dastard> <20101017022539.GA3317@amd> <87iq0za32l.fsf@basil.nowhere.org> <20101018162105.GB9571@infradead.org> <20101019070057.GA7770@amd> <20101019165044.GA13531@infradead.org> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: Nick Piggin , Andi Kleen , Dave Chinner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: Christoph Hellwig Return-path: Received: from www.tglx.de ([62.245.132.106]:35809 "EHLO www.tglx.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932896Ab0JXPpM (ORCPT ); Sun, 24 Oct 2010 11:45:12 -0400 In-Reply-To: <20101019165044.GA13531@infradead.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, 19 Oct 2010, Christoph Hellwig wrote: > On Tue, Oct 19, 2010 at 06:00:57PM +1100, Nick Piggin wrote: > > But it is still "magic". Because you don't even know whether it > > is a spin or sleeping lock, let alone whether it is irq or bh safe. > > You get far more information seeing a bit_spin_lock(0, &hlist) call > > than hlist_lock(). Errm, when hlist_lock() has proper documentation than it should not be rocket science to figure out what it does. And if you use bit 0 of hlist then you better have helper functions to access it anyway. We do that with other data types which (ab)use the lower two bits of pointers. > To get back a bit to the point: > > - we have a new bl_hlist sturcture which combines a hash list and a > lock embedded into the head > - the reason why we do it is to be able to use a bitlock And if you design that structure clever, then simple dereferencing of it (w/o casting magic) should make the compiler barf. So you are forced to use the helper functions. > Furthermore it allows the RT people to simply throw a mutex into the > head and everything keeps working without touching a sinlge line of > code outside of hlist_bl.h. Yes, please use proper helper functions. Having to change code is a horror for RT, when we can get away with a single change in a header file. Aside of RT there is another advantage of being able to change the lock implementation at a single place: you can change it to a real spinlock and have lockdep coverage of that code. I fundamentally hate bit_spin_locks for sneaking around lockdep. Thanks, tglx