From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ3oA-0004f7-6F for qemu-devel@nongnu.org; Wed, 04 Feb 2015 12:32:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJ3o4-0003b1-U2 for qemu-devel@nongnu.org; Wed, 04 Feb 2015 12:32:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42656) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ3o4-0003ap-M0 for qemu-devel@nongnu.org; Wed, 04 Feb 2015 12:32:04 -0500 Message-ID: <54D2578B.4050605@redhat.com> Date: Wed, 04 Feb 2015 18:31:55 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20150204172510.GA15571@flamenco> In-Reply-To: <20150204172510.GA15571@flamenco> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/3] rcu: use rcu_{dereference, assign_pointer} instead of atomic_rcu_{read, set} List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Emilio G. Cota" Cc: qemu-devel@nongnu.org On 04/02/2015 18:25, Emilio G. Cota wrote: > On Wed, Feb 04, 2015 at 11:01:00 +0100, Paolo Bonzini wrote: >> On 03/02/2015 23:08, Emilio G. Cota wrote: >>> This matches the semantics of liburcu. >> >> This is not necessary. The two sets of macros are exactly the same, so >> it's okay to use atomic_rcu_read/write. > > They're not exactly the same, otherwise the patch would be trivial. You're right, I was imprecise---I meant they are interoperable. You can use atomic_rcu_read/write together with liburcu, you do not need to use the liburcu-provided rcu_dereference/rcu_assign_pointer. Paolo > The difference can be seen in the change to the macros' documentation: > > On Tue, Feb 03, 2015 at 17:08:18 -0500, Emilio G. Cota wrote: >> This matches the semantics of liburcu. >> --- a/docs/rcu.txt >> +++ b/docs/rcu.txt > (snip) >> - typeof(*p) atomic_rcu_read(p); >> + typeof(p) rcu_dereference(p); > (snip) >> - void atomic_rcu_set(p, typeof(*p) v); >> + void rcu_assign_pointer(p, typeof(p) v); > > The liburcu macros take a variable (usually a pointer, hence the > macros' names, but unsigned long is also common), not its address. > > These changes require modifications to the calling code as well, e.g. > memory.c: > > struct AddressSpace { > ... > /* Accessed via RCU. */ > struct FlatView *current_map; > ... > }; > ... > struct FlatView *view; > ... > - view = atomic_rcu_read(&as->current_map); > + view = rcu_dereference(as->current_map); > ... > - atomic_rcu_set(&as->current_map, new_view); > + rcu_assign_pointer(as->current_map, new_view); > > Thanks, > > Emilio >