mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: Jonas Oberhauser <jonas.oberhauser@huaweicloud.com>
Cc: paulmck@kernel.org, stern@rowland.harvard.edu,
	parri.andrea@gmail.com, will@kernel.org, peterz@infradead.org,
	npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk,
	luc.maranget@inria.fr, akiyks@gmail.com, dlustig@nvidia.com,
	joel@joelfernandes.org, urezki@gmail.com,
	quic_neeraju@quicinc.com, frederic@kernel.org,
	linux-kernel@vger.kernel.org,
	Viktor Vafeiadis <viktor@mpi-sws.org>
Subject: Re: [PATCHv2 3/4] tools/memory-model: Define effect of Mb tags on RMWs in tools/...
Date: Mon, 17 Jun 2024 15:43:03 -0700	[thread overview]
Message-ID: <ZnC79zgNZsWTSdVQ@boqun-archlinux> (raw)
In-Reply-To: <5be2fcc0-0fd7-49d8-bc4b-12bf3e90a677@huaweicloud.com>

On Wed, Jun 05, 2024 at 09:56:31PM +0200, Jonas Oberhauser wrote:
> 
> 
> Am 6/5/2024 um 6:28 AM schrieb Boqun Feng:
> > On Tue, Jun 04, 2024 at 06:04:40PM +0200, Jonas Oberhauser wrote:
> > > Herd7 transforms successful RMW with Mb tags by inserting smp_mb() fences
> > > around them. We emulate this by considering imaginary po-edges before the
> > > RMW read and before the RMW write, and extending the smp_mb() ordering
> > > rule, which currently only applies to real po edges that would be found
> > > around a really inserted smp_mb(), also to cases of the only imagined po
> > > edges.
> > > 
> > > Reported-by: Viktor Vafeiadis <viktor@mpi-sws.org>
> > > Suggested-by: Alan Stern <stern@rowland.harvard.edu>
> > > Signed-off-by: Jonas Oberhauser <jonas.oberhauser@huaweicloud.com>
> > > ---
> > >   tools/memory-model/linux-kernel.cat | 10 ++++++++++
> > >   1 file changed, 10 insertions(+)
> > > 
> > > diff --git a/tools/memory-model/linux-kernel.cat b/tools/memory-model/linux-kernel.cat
> > > index adf3c4f41229..d7e7bf13c831 100644
> > > --- a/tools/memory-model/linux-kernel.cat
> > > +++ b/tools/memory-model/linux-kernel.cat
> > > @@ -34,6 +34,16 @@ let R4rmb = R \ Noreturn	(* Reads for which rmb works *)
> > >   let rmb = [R4rmb] ; fencerel(Rmb) ; [R4rmb]
> > >   let wmb = [W] ; fencerel(Wmb) ; [W]
> > >   let mb = ([M] ; fencerel(Mb) ; [M]) |
> > > +	(*
> > > +	 * full-barrier RMWs (successful cmpxchg(), xchg(), etc.) act as
> > > +	 * though there were enclosed by smp_mb().
> > > +	 * The effect of these virtual smp_mb() is formalized by adding
> > > +	 * Mb tags to the read and write of the operation, and providing
> > > +	 * the same ordering as though there were additional po edges
> > > +	 * between the Mb tag and the read resp. write.
> > > +	 *)
> > > +	([M] ; po ; [Mb & R]) |
> > > +	([Mb & W] ; po ; [M]) |
> > 
> > I couldn't help suggestting:
> > 
> > 	([M] ; po ; [Mb & domain(rmw)]) |
> > 	([Mb & range(rmw)] ; po ; [M]) |
> > 
> > , it's a bit more clear to me, but maybe the comment above is good
> > enough?
> 
> Hm, maybe clarity is in the eye of the beholder in this case.
> 
> Actually looking at your suggestion makes me think of smp_store_mb(), which
> although represented as Once;F[Mb] could be (mis)understood also as Mb&W.
> And it indeed does the same thing
>   ([Mb & W] ; po ; [M])
> would suggest.
> 
> (btw I think it is confusing that smp_store_mb is not strictly stronger than
> smp_store_release. Of course there are places where you want a relaxed store
> followed by an mb, but usually the mb versions are strictly stronger.).
> 

May not be a good idea to model smp_store_mb() as a (Mb & W), since the
purpose of smp_store_mb() is for SB pattern synchronization. Maybe it
has a bad name, but I think the intentation of smp_store_mb() is simply
a write + smp_mb(), rather than a MB write.

Regards,
Boqun

> Best wishes,
>   jonas
> 

  reply	other threads:[~2024-06-17 22:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04 15:29 [PATCHv2 0/4] tools/memory-model: Define more of LKMM in tools/memory-model Jonas Oberhauser
2024-06-04 16:00 ` [PATCHv2 1/4] tools/memory-model: Legitimize current use of tags in LKMM macros Jonas Oberhauser
2024-06-04 16:04 ` [PATCHv2 2/4] tools/memory-model: Define applicable tags on operation in tools/ Jonas Oberhauser
2024-06-05  4:25   ` Boqun Feng
2024-06-05  9:54     ` Jonas Oberhauser
2024-06-04 16:04 ` [PATCHv2 3/4] tools/memory-model: Define effect of Mb tags on RMWs " Jonas Oberhauser
2024-06-05  4:28   ` Boqun Feng
2024-06-05 13:40     ` Alan Stern
2024-06-05 19:56     ` Jonas Oberhauser
2024-06-17 22:43       ` Boqun Feng [this message]
2024-06-04 16:05 ` [PATCHv2 4/4] tools/memory-model: Distinguish between syntactic and semantic tags Jonas Oberhauser
2024-06-04 17:56 ` [PATCHv2 0/4] tools/memory-model: Define more of LKMM in tools/memory-model Alan Stern
2024-06-05 19:58   ` Jonas Oberhauser
2024-06-06 16:37     ` Paul E. McKenney
2024-06-10  8:04       ` Jonas Oberhauser
2024-06-10 15:21         ` Paul E. McKenney
2024-06-08  1:00     ` Alan Stern
2024-06-10  8:38       ` Hernan Ponce de Leon
2024-07-12  8:06         ` Hernan Ponce de Leon
2024-07-29 13:30           ` Hernan Ponce de Leon
2024-07-29 14:45             ` Jonas Oberhauser
2024-07-29 15:19               ` Hernan Ponce de Leon
2024-07-29 15:44                 ` Jonas Oberhauser
2024-07-29 15:53                   ` Hernan Ponce de Leon
2024-07-29 16:05                     ` Jonas Oberhauser
2024-06-10  9:08       ` Jonas Oberhauser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZnC79zgNZsWTSdVQ@boqun-archlinux \
    --to=boqun.feng@gmail.com \
    --cc=akiyks@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=dlustig@nvidia.com \
    --cc=frederic@kernel.org \
    --cc=j.alglave@ucl.ac.uk \
    --cc=joel@joelfernandes.org \
    --cc=jonas.oberhauser@huaweicloud.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luc.maranget@inria.fr \
    --cc=npiggin@gmail.com \
    --cc=parri.andrea@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=quic_neeraju@quicinc.com \
    --cc=stern@rowland.harvard.edu \
    --cc=urezki@gmail.com \
    --cc=viktor@mpi-sws.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®