From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZfmU-0006zB-7d for qemu-devel@nongnu.org; Wed, 09 Sep 2015 09:51:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZfmT-0003hq-5W for qemu-devel@nongnu.org; Wed, 09 Sep 2015 09:51:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZfmT-0003hj-0Z for qemu-devel@nongnu.org; Wed, 09 Sep 2015 09:51:21 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id AC2192E2427 for ; Wed, 9 Sep 2015 13:51:20 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-83.ams2.redhat.com [10.36.112.83]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t89DoEiP030571 for ; Wed, 9 Sep 2015 09:51:19 -0400 From: Paolo Bonzini Date: Wed, 9 Sep 2015 15:50:10 +0200 Message-Id: <1441806613-13775-41-git-send-email-pbonzini@redhat.com> In-Reply-To: <1441806613-13775-1-git-send-email-pbonzini@redhat.com> References: <1441806613-13775-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 40/43] tcg: add memory barriers in page_find_alloc accesses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org page_find is reading the radix tree outside all locks, so it has to use the RCU primitives. It does not need RCU critical sections because the PageDescs are never removed, so there is never a need to wait for the end of code sections that use a PageDesc. Signed-off-by: Paolo Bonzini --- translate-all.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/translate-all.c b/translate-all.c index 37bb56c..5329982 100644 --- a/translate-all.c +++ b/translate-all.c @@ -431,26 +431,26 @@ static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc) /* Level 2..N-1. */ for (i = V_L1_SHIFT / V_L2_BITS - 1; i > 0; i--) { - void **p = *lp; + void **p = atomic_rcu_read(lp); if (p == NULL) { if (!alloc) { return NULL; } p = g_new0(void *, V_L2_SIZE); - *lp = p; + atomic_rcu_set(lp, p); } lp = p + ((index >> (i * V_L2_BITS)) & (V_L2_SIZE - 1)); } - pd = *lp; + pd = atomic_rcu_read(lp); if (pd == NULL) { if (!alloc) { return NULL; } pd = g_new0(PageDesc, V_L2_SIZE); - *lp = pd; + atomic_rcu_set(lp, pd); } return pd + (index & (V_L2_SIZE - 1)); -- 2.4.3