All of lore.kernel.org
 help / color / mirror / Atom feed
From: Akira Yokosawa <akiyks@gmail.com>
To: Ignacio Encinas Rubio <ignacio@iencinas.com>
Cc: perfbook@vger.kernel.org, "Paul E. McKenney" <paulmck@kernel.org>,
	Akira Yokosawa <akiyks@gmail.com>
Subject: Re: Is Alpha non-other-multicopy atomic?
Date: Sun, 16 Mar 2025 20:37:19 +0900	[thread overview]
Message-ID: <64509d29-0593-4b7b-bb29-8a96835ac1bc@gmail.com> (raw)
In-Reply-To: <6c2c3199-e092-4909-853e-4fad1ca0f35c@iencinas.com>

[+Cc: Paul]

Hello,

I reflowed your message quoted below so that it fits 78 char width.

On Fri, 28 Feb 2025 18:31:02 +0100, Ignacio Encinas Rubio wrote:
> Hello!
> 
> I recently looked at memory consistency models with a particular focus
> on hardware details and found this book to be great, but I was left
> wondering about something regarding Alpha's memory model. 
> 
> I tried to find previous discussions about this but didn't find
> anything, so I'll go ahead:
> 
> Table 15.5: Summary of Memory Ordering states that Alpha is *NOT*
> Other-Multicopy Atomic but I couldn't find the explanation for this.
> Other sources contradict this statement [1] [2].
> [3] Documents ARM's adoption of other-multicopy atomicity, using POWER
> as an example of non-other-multicopy-atomicity but fails to mention Alpha.
> 
> Furthermore, [2] models non-other-multicopy-atomicity by having "Read
> from external" (rfe) not impose ordering. Alpha's reference manual [3]
> Section 5.6.1.5 states 
> 
>   If u is a write access Pi:W<m>(x,a) and v is an overlapping read
> access Pj:R<n>(y,b), u is visible to v only if:
>     - u <- v, or
>     - u precedes v in processor issue sequence (possible only if Pi=Pjn).

As is well known, Alpha is infamous of its lack of address-dependency
guarantees.  I don't see much point in discussing whether it is multicopy
atomic or not.

That said, here is a naive litmus test on Non multicopy atomicity:

---------------------------------------------------------------------
C NMCA

(* Demonstrate no-ordering of non-multicopy atomicity
 * Result: Sometimes -- Non-multicopy atomic platforms
                            (LKMM, Armv7, POWER, etc.)
           Never     -- Other-multicopy atomic platforms (e.g., x86, Armv8)
                     -- Full-multicopy atomic platform (s390)
 *)

{}

P0(int *x, int *y)
{
	int r0;
	int r1;

	r0 = READ_ONCE(*y);
	r1 = READ_ONCE(*x);
}

P1(int *x, int *y)
{
	int r0;
	int r1;

	r0 = READ_ONCE(*y);
	r1 = READ_ONCE(*x);
}

P2(int *x, int *y)
{
	WRITE_ONCE(*x, 1);
	WRITE_ONCE(*y, 1);
}

exists (0:r0=0 /\ 0:r1=1 /\ 1:r0=1 /\ 1:r1=0)
---------------------------------------------------------------------

If you have access to an Alpha machine with 3 or more CPUs,
you should be able to run this test with the help of klitmus7.

Note that you might need to run the test against pre-4.15 Linux release.
READ_ONCE() since 4.15 has smp_mb() for Alpha to ensure that it can
be used as a start point of an address dependency.  Litmus test
above might behave differently against Linux releases of pre and post
4.15 WRT Alpha.

Also note that even if you see a result saying "Never", it does not
necessarily mean Alpha architecture is other-multicopy-atomic or stronger.
The behavior might depend on specific memory/cache system found on a
specific model of the machine, for example.

Finally, my mental model of other-multi-copy might be different from
those defined in papers you cited below. 

> 
> Which seems to confirm that Alpha was indeed other-multicopy atomic.
> 
> Best regards,
> Ignacio
> 
> 
> [1] https://arxiv.org/pdf/1707.05923 - First page
> [2] http://www0.cs.ucl.ac.uk/staff/j.alglave/these.pdf - Section 4.2.3.1
> [3] https://dl.acm.org/doi/pdf/10.1145/3158107

  ([3]: with the last-minute edit in your follow-up.)

        Thanks, Akira


  parent reply	other threads:[~2025-03-16 11:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-28 17:31 Is Alpha non-other-multicopy atomic? Ignacio Encinas Rubio
2025-02-28 17:34 ` Ignacio Encinas Rubio
2025-03-16 11:37 ` Akira Yokosawa [this message]
2025-03-16 17:12   ` Ignacio Encinas Rubio
2025-03-17  9:58     ` Akira Yokosawa
2025-03-18 18:16       ` Ignacio Encinas Rubio

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=64509d29-0593-4b7b-bb29-8a96835ac1bc@gmail.com \
    --to=akiyks@gmail.com \
    --cc=ignacio@iencinas.com \
    --cc=paulmck@kernel.org \
    --cc=perfbook@vger.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 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.