From: "Jan Beulich" Subject: Re: [PATCHv4 1/3] rwlock: Add per-cpu reader-writer lock infrastructure Date: Fri, 18 Dec 2015 04:37:16 -0700 Message-ID: <5673FDFC02000078000C123F@prv-mh.provo.novell.com> References: <1450433179-17827-1-git-send-email-malcolm.crossley@citrix.com> <1450433179-17827-2-git-send-email-malcolm.crossley@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a9tLc-0001VQ-TJ for xen-devel@lists.xenproject.org; Fri, 18 Dec 2015 11:37:21 +0000 In-Reply-To: <1450433179-17827-2-git-send-email-malcolm.crossley@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: malcolm.crossley@citrix.com Cc: keir@xen.org, ian.campbell@citrix.com, george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com, dario.faggioli@citrix.com, Marcos.Matsunaga@oracle.com, stefano.stabellini@citrix.com, xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org >>> On 18.12.15 at 11:06, wrote: > @@ -492,6 +494,50 @@ int _rw_is_write_locked(rwlock_t *lock) > return (lock->lock == RW_WRITE_FLAG); /* writer in critical section? */ > } > > +void _percpu_write_lock(percpu_rwlock_t **per_cpudata, > + percpu_rwlock_t *percpu_rwlock) > +{ > + unsigned int cpu; > + cpumask_t *rwlock_readers = &this_cpu(percpu_rwlock_readers); > + > +#ifndef NDEBUG > + /* Validate the correct per_cpudata variable has been provided. */ > + ASSERT(per_cpudata == percpu_rwlock->percpu_owner); > +#endif At the first glance the #ifndef looks plain superfluous, but I understand that it's needed because we once decided to make ASSERT() evaluate its condition even on non-debug builds. However, to unclutter the use sites, you should probably put this into a macro or inline function. Everything else looks fine to me now. Jan