From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Piggin Subject: Re: [patch 1/2] kernel: introduce brlock Date: Wed, 17 Mar 2010 10:44:40 +1100 Message-ID: <20100316234440.GU2869@laptop> References: <20100316122213.GP2869@laptop> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Al Viro , Frank Mayhar , John Stultz , Andi Kleen , linux-fsdevel@vger.kernel.org To: Andreas Dilger Return-path: Received: from cantor2.suse.de ([195.135.220.15]:49827 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750988Ab0CPXoo (ORCPT ); Tue, 16 Mar 2010 19:44:44 -0400 Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, Mar 16, 2010 at 01:01:09PM -0600, Andreas Dilger wrote: > On 2010-03-16, at 06:22, Nick Piggin wrote: > >+#define DEFINE_BRLOCK(name) \ > >+ DEFINE_PER_CPU(spinlock_t, name##_lock); \ > >+ void name##_lock_init(void) { \ > >+ void name##_wlock(void) { \ > >+ void name##_wunlock(void) { \ > >+ int name##_atomic_dec_and_wlock__failed(atomic_t *a) { > > What makes these macros unpleasant is that it is no longer possible > to tag to the implementation to see what it does, since there is no > real declaration for these locks. > > Is it possible to change the macros to take the lock name as a > parameter, like normal lock/unlock functions do, and then have a > single declaration for br_lock_init(), br_wlock(), etc. macros? The problem is that then you can't do out of line functions, and things like wlock/wunlock are rather large. What I think I can do is add macros in the brlock.h file #define br_rlock(name) ##name_rlock() So the macro calls the right function and your tag should take you pretty close to the right place. Any better ideas how to implement this nicely would be welcome. It must be as light-weight as possible in the rlock path though.