From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPZ5a-0001lg-HQ for qemu-devel@nongnu.org; Wed, 12 Aug 2015 12:41:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZPZ5Z-0008BG-1I for qemu-devel@nongnu.org; Wed, 12 Aug 2015 12:41:18 -0400 Received: from mail-wi0-x22c.google.com ([2a00:1450:400c:c05::22c]:34885) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPZ5Y-0008Aw-Rs for qemu-devel@nongnu.org; Wed, 12 Aug 2015 12:41:16 -0400 Received: by wicne3 with SMTP id ne3so107788666wic.0 for ; Wed, 12 Aug 2015 09:41:16 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 12 Aug 2015 18:41:00 +0200 Message-Id: <1439397664-70734-9-git-send-email-pbonzini@redhat.com> In-Reply-To: <1439397664-70734-1-git-send-email-pbonzini@redhat.com> References: <1439397664-70734-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 08/10] 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 Cc: mttcg@greensocs.com, fred.konrad@greensocs.com 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/translate-all.c b/translate-all.c index 7727091..78a787d 100644 --- a/translate-all.c +++ b/translate-all.c @@ -437,14 +437,14 @@ 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)); @@ -456,7 +456,7 @@ static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc) return NULL; } pd = g_new0(PageDesc, V_L2_SIZE); - *lp = pd; + atomic_rcu_set(lp, pd); } return pd + (index & (V_L2_SIZE - 1)); -- 1.8.3.1