All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] docs/atomics: update comparison with Linux
@ 2016-05-25 12:26 Paolo Bonzini
  2016-05-25 15:15 ` Emilio G. Cota
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2016-05-25 12:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: cota, mttcg

Over time, some differences between QEMU and Linux atomics are getting
smoothed.  In particular, Linux grew atomic_fetch_or (and in general
the differences regarding RMW operations were not described accurately)
and smp_load_acquire/smp_store_release.  Also, set_mb was renamed to
smp_store_mb().  Include these changes in the documentation.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 docs/atomics.txt | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/docs/atomics.txt b/docs/atomics.txt
index 67a27ad..3f8b770 100644
--- a/docs/atomics.txt
+++ b/docs/atomics.txt
@@ -340,17 +340,27 @@ and memory barriers, and the equivalents in QEMU:
   properly aligned.
   No barriers are implied by atomic_read/set in either Linux or QEMU.
 
-- most atomic read-modify-write operations in Linux return void;
-  in QEMU, all of them return the old value of the variable.
+- atomic read-modify-write operations in Linux are of three kinds:
+
+         atomic_OP          returns void
+         atomic_OP_return   returns new value of the variable
+         atomic_fetch_OP    returns the old value of the variable
+         atomic_cmpxchg     returns the old value of the variable
+
+  In QEMU, the second kind does not exist.  Currently Linux has
+  atomic_fetch_or only; QEMU provides all of inc, dec, and, sub, and, or.
 
 - different atomic read-modify-write operations in Linux imply
   a different set of memory barriers; in QEMU, all of them enforce
   sequential consistency, which means they imply full memory barriers
   before and after the operation.
 
-- Linux does not have an equivalent of atomic_mb_read() and
-  atomic_mb_set().  In particular, note that set_mb() is a little
-  weaker than atomic_mb_set().
+- Linux does not have an equivalent of atomic_mb_set().  In particular,
+  note that smp_store_mb() is a little weaker than atomic_mb_set().
+  atomic_mb_read() compiles to the same instructions as Linux's
+  smp_load_acquire(), but this should be treated as an implementation
+  detail.  If required, QEMU might later add atomic_load_acquire() and
+  atomic_store_release() macros.
 
 
 SOURCES
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] docs/atomics: update comparison with Linux
  2016-05-25 12:26 [Qemu-devel] [PATCH] docs/atomics: update comparison with Linux Paolo Bonzini
@ 2016-05-25 15:15 ` Emilio G. Cota
  2016-05-25 15:29   ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Emilio G. Cota @ 2016-05-25 15:15 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, mttcg

On Wed, May 25, 2016 at 14:26:06 +0200, Paolo Bonzini wrote:
> Over time, some differences between QEMU and Linux atomics are getting
> smoothed.  In particular, Linux grew atomic_fetch_or (and in general
> the differences regarding RMW operations were not described accurately)
> and smp_load_acquire/smp_store_release.  Also, set_mb was renamed to
> smp_store_mb().  Include these changes in the documentation.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  docs/atomics.txt | 20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/docs/atomics.txt b/docs/atomics.txt
> index 67a27ad..3f8b770 100644
> --- a/docs/atomics.txt
> +++ b/docs/atomics.txt
> @@ -340,17 +340,27 @@ and memory barriers, and the equivalents in QEMU:
>    properly aligned.
>    No barriers are implied by atomic_read/set in either Linux or QEMU.
>  
> -- most atomic read-modify-write operations in Linux return void;
> -  in QEMU, all of them return the old value of the variable.
> +- atomic read-modify-write operations in Linux are of three kinds:
> +
> +         atomic_OP          returns void
> +         atomic_OP_return   returns new value of the variable
> +         atomic_fetch_OP    returns the old value of the variable
> +         atomic_cmpxchg     returns the old value of the variable
> +
> +  In QEMU, the second kind does not exist.  Currently Linux has
> +  atomic_fetch_or only; QEMU provides all of inc, dec, and, sub, and, or.

Not clear whether the last 'and' is redundant or is being used as
a conjunction. Either way it would be clearer to just remove it.

Other than that:
  Reviewed-by: Emilio G. Cota <cota@braap.org>

		Emilio

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] docs/atomics: update comparison with Linux
  2016-05-25 15:15 ` Emilio G. Cota
@ 2016-05-25 15:29   ` Paolo Bonzini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2016-05-25 15:29 UTC (permalink / raw)
  To: Emilio G. Cota; +Cc: mttcg, qemu-devel



On 25/05/2016 17:15, Emilio G. Cota wrote:
>> > +
>> > +  In QEMU, the second kind does not exist.  Currently Linux has
>> > +  atomic_fetch_or only; QEMU provides all of inc, dec, and, sub, and, or.
> Not clear whether the last 'and' is redundant or is being used as
> a conjunction. Either way it would be clearer to just remove it.

The first "and" is "add". :)

Thanks,

Paolo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-05-25 15:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-25 12:26 [Qemu-devel] [PATCH] docs/atomics: update comparison with Linux Paolo Bonzini
2016-05-25 15:15 ` Emilio G. Cota
2016-05-25 15:29   ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.