Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1679992

Re: [PATCH] doc: Update memory-barriers.txt for read-to-write dependencies

From Will Deacon <will.deacon@arm.com>
Newsgroups linux.kernel
Subject Re: [PATCH] doc: Update memory-barriers.txt for read-to-write dependencies
Date 2017-07-03 15:10 +0200
Message-ID <tZ9h2-1TK-39@gated-at.bofh.it> (permalink)
References <tYdwl-3rt-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Paul,

On Fri, Jun 30, 2017 at 04:28:10PM -0700, Paul E. McKenney wrote:
> The memory-barriers.txt document contains an obsolete passage stating that
> smp_read_barrier_depends() is required to force ordering for read-to-write
> dependencies.  We now know that this is not required, even for DEC Alpha.
> This commit therefore updates this passage to state that read-to-write
> dependencies are respected even without smp_read_barrier_depends().
> 
> Reported-by: Lance Roy <ldr709@gmail.com>
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Cc: David Howells <dhowells@redhat.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Andrea Parri <parri.andrea@gmail.com>
> Cc: Jade Alglave <j.alglave@ucl.ac.uk>
> Cc: Luc Maranget <luc.maranget@inria.fr>
> 
> diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
> index 9d5e0f853f08..a8a91b9d5a1b 100644
> --- a/Documentation/memory-barriers.txt
> +++ b/Documentation/memory-barriers.txt
> @@ -594,7 +594,10 @@ between the address load and the data load:
>  This enforces the occurrence of one of the two implications, and prevents the
>  third possibility from arising.
>  
> -A data-dependency barrier must also order against dependent writes:
> +A data-dependency barrier is not required to order dependent writes
> +because the CPUs that the Linux kernel supports don't do writes until
> +they are certain (1) that the write will actually happen, (2) of the
> +location of the write, and (3) of the value to be written.

Might be worth mentioning that you have to careful with the compiler here,
and pointing to the section on "Control dependencies" so that people don't
just take these three points as guarantees in isolation.

>  
>  	CPU 1		      CPU 2
>  	===============	      ===============
> @@ -603,19 +606,19 @@ A data-dependency barrier must also order against dependent writes:
>  	<write barrier>
>  	WRITE_ONCE(P, &B);
>  			      Q = READ_ONCE(P);
> -			      <data dependency barrier>
>  			      *Q = 5;

Do we want that write to Q to be a WRITE_ONCE? Again, the control
dependencies section does call this out.

Will

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] doc: Update memory-barriers.txt for read-to-write  dependencies "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-07-01 01:30 +0200
  Re: [PATCH] doc: Update memory-barriers.txt for read-to-write  dependencies Will Deacon <will.deacon@arm.com> - 2017-07-03 15:10 +0200
    Re: [PATCH] doc: Update memory-barriers.txt for read-to-write  dependencies "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-07-03 19:50 +0200
      Re: [PATCH] doc: Update memory-barriers.txt for read-to-write  dependencies Will Deacon <will.deacon@arm.com> - 2017-07-04 18:40 +0200
        Re: [PATCH] doc: Update memory-barriers.txt for read-to-write  dependencies "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-07-04 23:50 +0200
          Re: [PATCH] doc: Update memory-barriers.txt for read-to-write  dependencies Will Deacon <will.deacon@arm.com> - 2017-07-05 11:50 +0200

csiph-web