lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 4 Sep 2020 08:59:21 +0800
From:   Boqun Feng <boqun.feng@...il.com>
To:     "Paul E. McKenney" <paulmck@...nel.org>
Cc:     peterz@...radead.org, linux-kernel@...r.kernel.org,
        linux-arch@...r.kernel.org, kernel-team@...com, mingo@...nel.org,
        stern@...land.harvard.edu, parri.andrea@...il.com, will@...nel.org,
        npiggin@...il.com, dhowells@...hat.com, j.alglave@....ac.uk,
        luc.maranget@...ia.fr, akiyks@...il.com
Subject: Re: [PATCH kcsan 6/9] tools/memory-model: Expand the cheatsheet.txt
 notion of relaxed

On Thu, Sep 03, 2020 at 04:30:37PM -0700, Paul E. McKenney wrote:
> On Wed, Sep 02, 2020 at 08:37:15PM +0800, Boqun Feng wrote:
> > On Wed, Sep 02, 2020 at 12:14:12PM +0200, peterz@...radead.org wrote:
> > > On Wed, Sep 02, 2020 at 11:54:48AM +0800, Boqun Feng wrote:
> > > > On Mon, Aug 31, 2020 at 11:20:34AM -0700, paulmck@...nel.org wrote:
> > > > > From: "Paul E. McKenney" <paulmck@...nel.org>
> > > > > 
> > > > > This commit adds a key entry enumerating the various types of relaxed
> > > > > operations.
> > > > > 
> > > > > Signed-off-by: Paul E. McKenney <paulmck@...nel.org>
> > > > > ---
> > > > >  tools/memory-model/Documentation/cheatsheet.txt | 27 ++++++++++++++-----------
> > > > >  1 file changed, 15 insertions(+), 12 deletions(-)
> > > > > 
> > > > > diff --git a/tools/memory-model/Documentation/cheatsheet.txt b/tools/memory-model/Documentation/cheatsheet.txt
> > > > > index 33ba98d..31b814d 100644
> > > > > --- a/tools/memory-model/Documentation/cheatsheet.txt
> > > > > +++ b/tools/memory-model/Documentation/cheatsheet.txt
> > > > > @@ -5,7 +5,7 @@
> > > > >  
> > > > >  Store, e.g., WRITE_ONCE()            Y                                       Y
> > > > >  Load, e.g., READ_ONCE()              Y                          Y   Y        Y
> > > > > -Unsuccessful RMW operation           Y                          Y   Y        Y
> > > > > +Relaxed operation                    Y                          Y   Y        Y
> > > > >  rcu_dereference()                    Y                          Y   Y        Y
> > > > >  Successful *_acquire()               R                   Y  Y   Y   Y    Y   Y
> > > > >  Successful *_release()         C        Y  Y    Y     W                      Y
> > > > > @@ -17,14 +17,17 @@ smp_mb__before_atomic()       CP        Y  Y    Y        a  a   a   a    Y
> > > > >  smp_mb__after_atomic()        CP        a  a    Y        Y  Y   Y   Y    Y
> > > > >  
> > > > >  
> > > > > -Key:	C:	Ordering is cumulative
> > > > > -	P:	Ordering propagates
> > > > > -	R:	Read, for example, READ_ONCE(), or read portion of RMW
> > > > > -	W:	Write, for example, WRITE_ONCE(), or write portion of RMW
> > > > > -	Y:	Provides ordering
> > > > > -	a:	Provides ordering given intervening RMW atomic operation
> > > > > -	DR:	Dependent read (address dependency)
> > > > > -	DW:	Dependent write (address, data, or control dependency)
> > > > > -	RMW:	Atomic read-modify-write operation
> > > > > -	SELF:	Orders self, as opposed to accesses before and/or after
> > > > > -	SV:	Orders later accesses to the same variable
> > > > > +Key:	Relaxed:  A relaxed operation is either a *_relaxed() RMW
> > > > > +		  operation, an unsuccessful RMW operation, or one of
> > > > > +		  the atomic_read() and atomic_set() family of operations.
> > > > 
> > > > To be accurate, atomic_set() doesn't return any value, so it cannot be
> > > > ordered against DR and DW ;-)
> > > 
> > > Surely DW is valid for any store.
> > > 
> > 
> > IIUC, the DW colomn stands for whether the corresponding operation (in
> > this case, it's atomic_set()) is ordered any write that depends on this
> > operation. I don't think there is a write->write dependency, so DW for
> > atomic_set() should not be Y, just as the DW for WRITE_ONCE().
> > 
> > > > I think we can split the Relaxed family into two groups:
> > > > 
> > > > void Relaxed: atomic_set() or atomic RMW operations that don't return
> > > >               any value (e.g atomic_inc())
> > > > 
> > > > non-void Relaxed: a *_relaxed() RMW operation, an unsuccessful RMW
> > > >                   operation, or atomic_read().
> > > > 
> > > > And "void Relaxed" is similar to WRITE_ONCE(), only has "Self" and "SV"
> > > > equal "Y", while "non-void Relaxed" plays the same rule as "Relaxed"
> > > > in this patch.
> > > > 
> > > > Thoughts?
> > > 
> > > I get confused by the mention of all this atomic_read() atomic_set()
> > > crud in the first place, why are they called out specifically from any
> > > other regular load/store ?
> > 
> > Agreed. Probably we should fold those two operations into "Load" and
> > "Store" cases.
> 
> All good points.
> 
> How about like this, adding "Relaxed" to the WRITE_ONCE() and READ_ONCE()
> rows and "RMW" to the "Relaxed operation" row?
> 

Much better now, thanks! However ...

> The file contents are followed by a diff against the previous version.
> 
> 							Thanx, Paul
> 
> ------------------------------------------------------------------------
> 
>                                   Prior Operation     Subsequent Operation
>                                   ---------------  ---------------------------
>                                C  Self  R  W  RMW  Self  R  W  DR  DW  RMW  SV
>                               --  ----  -  -  ---  ----  -  -  --  --  ---  --
> 
> Relaxed store                        Y                                       Y
> Relaxed load                         Y                          Y   Y        Y
> Relaxed RMW operation                Y                          Y   Y        Y

void Relaxed RMW operation is still missing ;-) Maybe:

  void Relaxed RMW operation           Y                                       Y

> rcu_dereference()                    Y                          Y   Y        Y
> Successful *_acquire()               R                   Y  Y   Y   Y    Y   Y
> Successful *_release()         C        Y  Y    Y     W                      Y
> smp_rmb()                               Y       R        Y      Y        R
> smp_wmb()                                  Y    W           Y       Y    W
> smp_mb() & synchronize_rcu()  CP        Y  Y    Y        Y  Y   Y   Y    Y
> Successful full non-void RMW  CP     Y  Y  Y    Y     Y  Y  Y   Y   Y    Y   Y
> smp_mb__before_atomic()       CP        Y  Y    Y        a  a   a   a    Y
> smp_mb__after_atomic()        CP        a  a    Y        Y  Y   Y   Y    Y
> 
> 
> Key:	Relaxed:  A relaxed operation is either a *_relaxed() RMW
> 		  operation, an unsuccessful RMW operation, READ_ONCE(),
> 		  WRITE_ONCE(), or one of the atomic_read() and
> 		  atomic_set() family of operations.

And:
		  a RMW operation that doesn't return any value (e.g
		  atomic_inc()), IOW it's a void Relaxed operation.

Thoughts?

Regards,
Boqun

> 	C:	  Ordering is cumulative
> 	P:	  Ordering propagates
> 	R:	  Read, for example, READ_ONCE(), or read portion of RMW
> 	W:	  Write, for example, WRITE_ONCE(), or write portion of RMW
> 	Y:	  Provides ordering
> 	a:	  Provides ordering given intervening RMW atomic operation
> 	DR:	  Dependent read (address dependency)
> 	DW:	  Dependent write (address, data, or control dependency)
> 	RMW:	  Atomic read-modify-write operation
> 	SELF:	  Orders self, as opposed to accesses before and/or after
> 	SV:	  Orders later accesses to the same variable
> 
> ------------------------------------------------------------------------
> 
> diff --git a/tools/memory-model/Documentation/cheatsheet.txt b/tools/memory-model/Documentation/cheatsheet.txt
> index 31b814d..4146b8d 100644
> --- a/tools/memory-model/Documentation/cheatsheet.txt
> +++ b/tools/memory-model/Documentation/cheatsheet.txt
> @@ -3,9 +3,9 @@
>                                 C  Self  R  W  RMW  Self  R  W  DR  DW  RMW  SV
>                                --  ----  -  -  ---  ----  -  -  --  --  ---  --
>  
> -Store, e.g., WRITE_ONCE()            Y                                       Y
> -Load, e.g., READ_ONCE()              Y                          Y   Y        Y
> -Relaxed operation                    Y                          Y   Y        Y
> +Relaxed store                        Y                                       Y
> +Relaxed load                         Y                          Y   Y        Y
> +Relaxed RMW operation                Y                          Y   Y        Y
>  rcu_dereference()                    Y                          Y   Y        Y
>  Successful *_acquire()               R                   Y  Y   Y   Y    Y   Y
>  Successful *_release()         C        Y  Y    Y     W                      Y
> @@ -18,8 +18,9 @@ smp_mb__after_atomic()        CP        a  a    Y        Y  Y   Y   Y    Y
>  
>  
>  Key:	Relaxed:  A relaxed operation is either a *_relaxed() RMW
> -		  operation, an unsuccessful RMW operation, or one of
> -		  the atomic_read() and atomic_set() family of operations.
> +		  operation, an unsuccessful RMW operation, READ_ONCE(),
> +		  WRITE_ONCE(), or one of the atomic_read() and
> +		  atomic_set() family of operations.
>  	C:	  Ordering is cumulative
>  	P:	  Ordering propagates
>  	R:	  Read, for example, READ_ONCE(), or read portion of RMW

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ