From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJHwD-0003hc-R9 for qemu-devel@nongnu.org; Thu, 05 Feb 2015 03:37:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJHwA-0007Q5-Hw for qemu-devel@nongnu.org; Thu, 05 Feb 2015 03:37:25 -0500 Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]:39793) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJHwA-0007Q0-BH for qemu-devel@nongnu.org; Thu, 05 Feb 2015 03:37:22 -0500 Received: by mail-wi0-f182.google.com with SMTP id n3so8838949wiv.3 for ; Thu, 05 Feb 2015 00:37:21 -0800 (PST) Sender: Paolo Bonzini Message-ID: <54D32BBC.3030302@redhat.com> Date: Thu, 05 Feb 2015 09:37:16 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1422967948-3261-1-git-send-email-pbonzini@redhat.com> <1422967948-3261-6-git-send-email-pbonzini@redhat.com> <20150205062301.GA18713@ad.nay.redhat.com> In-Reply-To: <20150205062301.GA18713@ad.nay.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 5/9] exec: protect mru_block with RCU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, fred.konrad@greensocs.com On 05/02/2015 07:23, Fam Zheng wrote: >> > @@ -1381,14 +1397,16 @@ static ram_addr_t ram_block_add(RAMBlock *new_block, Error **errp) >> > QTAILQ_INSERT_TAIL(&ram_list.blocks, new_block, next); >> > } >> > ram_list.mru_block = NULL; >> > + atomic_rcu_set(&ram_list.version, ram_list.version + 1); >> > >> > - ram_list.version++; > Why is this not atomic_inc Because writes are protected by the ramlist lock. atomic_inc is more expensive. > (or why is atomic_rcu_set necessary here)? I probably should move it to patch 9; it is needed to update the list before ram_list.version. If you prefer I can change it to smp_wmb(); atomic_set(&ram_list.version, ram_list.version + 1); ? Paolo