From: Muli Ben-Yehuda Subject: Re: [PATCH 3/4] Support accelerated network plugin modules Date: Wed, 9 May 2007 15:17:07 +0300 Message-ID: <20070509121707.GQ4313@rhun.haifa.ibm.com> References: <1178618109.4147.35.camel@moonstone.uk.level5networks.com> <20070509112510.GO4313@rhun.haifa.ibm.com> <1178711887.4406.15.camel@moonstone.uk.level5networks.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1178711887.4406.15.camel@moonstone.uk.level5networks.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Kieran Mansley Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On Wed, May 09, 2007 at 12:58:06PM +0100, Kieran Mansley wrote: > > > +#define NETFRONT_LOCK_AND_CALL_ACCELERATOR_HOOK(_np, _hook, > _args...) \ > > > + do { > \ > > > + unsigned _flags; > \ > > > + spin_lock_irqsave(&(_np)->accelerator_lock, > _flags); \ > > > + if((_np)->accelerator && (_np)- > >accel_vif_state.hooks) \ > > > + (_np)->accel_vif_state.hooks->_hook(_args); > \ > > > + spin_unlock_irqrestore(&(_np)->accelerator_lock, > _flags); \ > > > + } while(0) > > > > Please get rid of these macros - it's not exactly a lot of code to > > duplicate and it makes it obvious what's going on. > > The first macro I'm happy to get rid of - I noticed after Keir > commented on the use of caps in the name that it's no longer used. > The second I think is enough code that it would unnecessarily > clutter the existing functions. For this reason I'd rather leave it > in (with a lower-case name). It's a matter of taste, but I'd prefer it if it was obvious when looking at the code that the hook is being called with a spinlock held. That's actually another thing - why must every hook be called with the spinlock held? if it's to protect the accelerator from going away, what's actually needed is a ref count (struct kref) on the accelerator. Cheers, Muli