qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/3] rcu: use rcu_{dereference, assign_pointer}


From: Emilio G. Cota
Subject: Re: [Qemu-devel] [PATCH 2/3] rcu: use rcu_{dereference, assign_pointer} instead of atomic_rcu_{read, set}
Date: Wed, 4 Feb 2015 12:25:10 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

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.

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]