From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9NCU-0004jg-Kz for qemu-devel@nongnu.org; Wed, 16 Dec 2015 20:17:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9NCQ-0007xt-0x for qemu-devel@nongnu.org; Wed, 16 Dec 2015 20:17:46 -0500 Received: from [59.151.112.132] (port=20694 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9NCP-0007w7-LC for qemu-devel@nongnu.org; Wed, 16 Dec 2015 20:17:41 -0500 References: <1450265542-4323-1-git-send-email-pbonzini@redhat.com> From: Wen Congyang Message-ID: <56720D09.1080908@cn.fujitsu.com> Date: Thu, 17 Dec 2015 09:16:57 +0800 MIME-Version: 1.0 In-Reply-To: <1450265542-4323-1-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] rcu: optimize rcu_read_lock List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org On 12/16/2015 07:32 PM, Paolo Bonzini wrote: > rcu_read_lock cannot change rcu_gp_ongoing from true to false > (the previous value of p_rcu_reader->ctr is zero), hence > there is no need to check p_rcu_reader->waiting and wake up > a concurrent synchronize_rcu. > > While at it mark the wakeup as unlikely in rcu_read_unlock. > > Signed-off-by: Paolo Bonzini Reviewed-by: Wen Congyang > --- > include/qemu/rcu.h | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/include/qemu/rcu.h b/include/qemu/rcu.h > index f6d1d56..7c7cca7 100644 > --- a/include/qemu/rcu.h > +++ b/include/qemu/rcu.h > @@ -88,10 +88,6 @@ static inline void rcu_read_lock(void) > > ctr = atomic_read(&rcu_gp_ctr); > atomic_xchg(&p_rcu_reader->ctr, ctr); > - if (atomic_read(&p_rcu_reader->waiting)) { > - atomic_set(&p_rcu_reader->waiting, false); > - qemu_event_set(&rcu_gp_event); > - } > } > > static inline void rcu_read_unlock(void) > @@ -104,7 +100,7 @@ static inline void rcu_read_unlock(void) > } > > atomic_xchg(&p_rcu_reader->ctr, 0); > - if (atomic_read(&p_rcu_reader->waiting)) { > + if (unlikely(atomic_read(&p_rcu_reader->waiting))) { > atomic_set(&p_rcu_reader->waiting, false); > qemu_event_set(&rcu_gp_event); > } >