linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kenneth-Lee-2012@foxmail.com
To: Andrea Parri <parri.andrea@gmail.com>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	linux-kernel@vger.kernel.org, paulmck@kernel.org
Subject: Re: Question about PB rule of LKMM
Date: Mon, 11 Mar 2024 11:41:26 +0800	[thread overview]
Message-ID: <tencent_9C4C2E93BF6E6F9A61B2C8B72B800839BD05@qq.com> (raw)
In-Reply-To: <Ze0afrfXMe4oJ4ez@andrea>

On Sun, Mar 10, 2024 at 03:27:10AM +0100, Andrea Parri wrote:
> Date: Sun, 10 Mar 2024 03:27:10 +0100
> From: Andrea Parri <parri.andrea@gmail.com>
> To: Kenneth-Lee-2012@foxmail.com
> Cc: Alan Stern <stern@rowland.harvard.edu>, linux-kernel@vger.kernel.org,
>  paulmck@kernel.org
> Subject: Re: Question about PB rule of LKMM
> 
> > > Remark that, in the CAT language, the identity relation ({(e, e) : each event e})
> > > is a subset of R* (the _reflexive_-transitive closure of R) for any relation R.
> > > 
> > > The link at stake, (P0:Wx1, P0:Rx), is the result of the following composition:
> > > 
> > >   [Marked]         ; (overwrite & ext)? ; cumul-fence*     ; [Marked]          ; rfe?            ; [Marked]
> > >   (P0:Wx1, P0:Wx1)   (P0:Wx1, P1:Wx8)     (P1:Wx8, P1:Wx8)   (P1:Wx8, P1:Wx8))   (P1:Wx8, P0:Rx)   (P0:Rx, P0:Rx)
> > > 
> > 
> > So the cumul-fence relation includes the same Store? This is hard to
> > understand, because it is defined as:
> > 
> >   let cumul-fence = [Marked] ; (A-cumul(strong-fence | po-rel) | wmb |
> > 	po-unlock-lock-po) ; [Marked] ; rmw-sequence
> > 
> > There is at lease a rmw-sequence in the relation link.
> > 
> > I doubt we have different understanding on the effect of
> > reflexive operator. Let's discuss this with an example. Say we have two
> > relation r1 and r2. r1 have (e1, e2) while r2 have (e2, e3). Then we got
> > (e1, e3) for (r1;r2). The (;) operator joins r1's range to r2's domain.
> > 
> > If we upgrade (r1;r2) to  (r1?;r2), (r1?) become {(m1, m1), (m1, m2), (m2,
> > m2)}, it is r1 plus all identity of all elements used in r1's relations.
> > 
> > So (r1?;r2) is {(m1, m3), (m2, m3)}. If we consider this link:
> > 
> >   e1 ->r1 ->e2 ->r2 e3
> > 
> > A question mark on r1 means both (e1, e3) and (e2, e3) are included in
> > the final definition. The r1 is ignore-able in the definition. The event
> > before or behind the ignore-able relation both belong to the definition.
> > 
> > But this doesn't means r1 is optional. If r1 is empty, (r1?;r2) will
> > become empty, because there is no event element in r1's relations.
> > 
> > So I think the reflexive-transitive operation on cumul-fence cannot make
> > this relation optional. You should first have such link in the code.
> 
> In Cat, r1? is better described by (following your own wording) "r1 plus
> all identity of all elements (i.e. not necessarily in r1)".
> 
> As an example, in the scenario at stake, cumul-fence is empty while both
> cumul-fence? and cumul-fence* match the identity relation on all events.
> 
> Here is a (relatively old, but still accurate AFAICR) article describing
> these and other notions as used in Herd:  (cf. table at the bottom)
> 
>   https://mirrors.edge.kernel.org/pub/linux/kernel/people/paulmck/LWNLinuxMM/herd.html
> 
> Said this, I do think the best way to familiarize with these notions and
> check one's understanding is to spend time using the herd tool itself.
> 

Excuse me, May I ask one last question? I tried the herd tool on the
discussed example. But it seems it is not protected by the hb acyclic
rule. I can replace the linux-kernel.cat with lock.cat on the test:

	P0(int *x)
	{
		int r1;
		WRITE_ONCE(*x, 1);
		r1 = READ_ONCE(*x);
	}
	P1(int *x)
	{
		WRITE_ONCE(*x, 8);
	}
	locations[0:r1; x]
	exists (0:r1=8)

It can still ensure the P0:Wx execute before P0:Rx:

	Test test Allowed
	States 3
	0:r1=1; [x]=1;
	0:r1=1; [x]=8;
	0:r1=8; [x]=8;
	Ok
	Witnesses
	Positive: 1 Negative: 2
	Condition exists (0:r1=8)
	Observation test Sometimes 1 2

The example doesn't prove the hb rule is necessary. Is this
understanding correct? Thanks.

>   Andrea

-- 
			-Kenneth Lee


  parent reply	other threads:[~2024-03-11  3:42 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01  3:18 Question about PB rule of LKMM Kenneth-Lee-2012
2024-03-05 18:00 ` Andrea Parri
2024-03-06  9:53   ` Kenneth-Lee-2012
2024-03-06 17:36     ` Andrea Parri
2024-03-06 18:29       ` Alan Stern
2024-03-06 19:24         ` Andrea Parri
2024-03-07  0:45           ` Kenneth-Lee-2012
2024-03-07 15:52           ` Andrea Parri
2024-03-07 17:25             ` Alan Stern
2024-03-07 18:18               ` Andrea Parri
2024-03-07 18:30                 ` Alan Stern
2024-03-07 19:08                   ` Andrea Parri
2024-03-07 19:46                     ` Alan Stern
2024-03-07 21:06                       ` Andrea Parri
2024-03-08 17:54                         ` Alan Stern
2024-03-08 21:29                           ` Andrea Parri
2024-03-08  3:10                     ` Kenneth-Lee-2012
2024-03-08 21:38                       ` Andrea Parri
2024-03-09  5:43                         ` Kenneth-Lee-2012
2024-03-10  2:27                           ` Andrea Parri
2024-03-10  2:52                             ` Kenneth-Lee-2012
2024-03-11  3:41                             ` Kenneth-Lee-2012 [this message]
     [not found]                             ` <20240311034104.7iffcia4k5rxvgog@kllt01>
2024-03-11  8:20                               ` Kenneth-Lee-2012

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=tencent_9C4C2E93BF6E6F9A61B2C8B72B800839BD05@qq.com \
    --to=kenneth-lee-2012@foxmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=parri.andrea@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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;
as well as URLs for NNTP newsgroup(s).