From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJIm9-0005BN-Pi for qemu-devel@nongnu.org; Thu, 05 Feb 2015 04:31:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJIm6-0001Nz-KE for qemu-devel@nongnu.org; Thu, 05 Feb 2015 04:31:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60984) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJIm6-0001Nv-DF for qemu-devel@nongnu.org; Thu, 05 Feb 2015 04:31:02 -0500 Date: Thu, 5 Feb 2015 17:30:55 +0800 From: Fam Zheng Message-ID: <20150205093055.GD5048@ad.nay.redhat.com> 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> <54D32BBC.3030302@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54D32BBC.3030302@redhat.com> 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: Paolo Bonzini Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, fred.konrad@greensocs.com On Thu, 02/05 09:37, Paolo Bonzini wrote: > > > 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. OK! > > > (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); > > ? > Yes, this looks more obvious :) Fam