From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9cef-00028p-Ru for qemu-devel@nongnu.org; Thu, 17 Dec 2015 12:47:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9cee-00070l-Nk for qemu-devel@nongnu.org; Thu, 17 Dec 2015 12:47:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9cee-00070b-A0 for qemu-devel@nongnu.org; Thu, 17 Dec 2015 12:47:52 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id E513591D04 for ; Thu, 17 Dec 2015 17:47:51 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-23.ams2.redhat.com [10.36.112.23]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBHHkfcg014618 for ; Thu, 17 Dec 2015 12:47:51 -0500 From: Paolo Bonzini Date: Thu, 17 Dec 2015 18:46:36 +0100 Message-Id: <1450374401-31352-41-git-send-email-pbonzini@redhat.com> In-Reply-To: <1450374401-31352-1-git-send-email-pbonzini@redhat.com> References: <1450374401-31352-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 40/45] rcu: optimize rcu_read_lock List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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. Reviewed-by: Wen Congyang Signed-off-by: Paolo Bonzini Message-Id: <1450265542-4323-1-git-send-email-pbonzini@redhat.com> --- 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); } -- 2.5.0