From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Andrea Parri <andrea@rivosinc.com>
Cc: Palmer Dabbelt <palmer@rivosinc.com>,
alex.bennee@linaro.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] RISC-V: Add support for Ztso
Date: Thu, 13 Oct 2022 10:59:39 +0100 [thread overview]
Message-ID: <Y0fhi2/hcvb37uiO@work-vm> (raw)
In-Reply-To: <Y0fX/VloiH7Bqewm@andrea>
* Andrea Parri (andrea@rivosinc.com) wrote:
> > > > Is x86's brand of memory ordering strong enough for Ztso?
> > > > I thought x86 had an optimisation where it was allowed to store forward
> > > > within the current CPU causing stores not to be quite strictly ordered.
>
> [...]
>
> > then a bit further down, '8.2.3.5 Intra-Processor Forwarding Is Allowed'
> > has an example and says
> >
> > 'The memory-ordering model allows concurrent stores by two processors to be seen in
> > different orders by those two processors; specifically, each processor may perceive
> > its own store occurring before that of the other.'
> >
> > Having said that, I remember it's realyl difficult to trigger; it's ~10
> > years since I saw an example to trigger it, and can't remember it.
>
> AFAICT, Ztso allows the forwarding in question too. Simulations with
> the axiomatic formalization confirm such expectation:
OK that seems to be what it says in:
https://five-embeddev.com/riscv-isa-manual/latest/ztso.html
'In both of these memory models, it is the that allows a hart to
forward a value from its store buffer to a subsequent (in program order)
load—that is to say that stores can be forwarded locally before they are
visible to other harts'
> RISCV intra-processor-forwarding
> {
> 0:x5=1; 0:x6=x; 0:x8=y;
> 1:x5=1; 1:x6=y; 1:x8=x;
> }
> P0 | P1 ;
> sw x5,0(x6) | sw x5,0(x6) ;
> lw x9,0(x6) | lw x9,0(x6) ;
> lw x7,0(x8) | lw x7,0(x8) ;
> exists
> (0:x7=0 /\ 1:x7=0 /\ 0:x9=1 /\ 1:x9=1)
(I'm a bit fuzzy reading this...)
So is that the interesting case - where x7 is saying neither processor
saw the other processors write yet, but they did see their own?
So from a qemu patch perspective, I think the important thing is that
the flag that's defined, is defined and commented in such a way that
it's obvious that local forwarding is allowed; we wouldn't want someone
emulating a stricter CPU (that doesn't allow local forwarding) to go and
use this flag as an indication that the host cpu is that strict.
Dave
> Test intra-processor-forwarding Allowed
> States 4
> 0:x7=0; 0:x9=1; 1:x7=0; 1:x9=1;
> 0:x7=0; 0:x9=1; 1:x7=1; 1:x9=1;
> 0:x7=1; 0:x9=1; 1:x7=0; 1:x9=1;
> 0:x7=1; 0:x9=1; 1:x7=1; 1:x9=1;
> Ok
> Witnesses
> Positive: 1 Negative: 3
> Condition exists (0:x7=0 /\ 1:x7=0 /\ 0:x9=1 /\ 1:x9=1)
> Observation intra-processor-forwarding Sometimes 1 3
> Time intra-processor-forwarding 0.00
> Hash=518e4b9b2f0770c94918ac5d7e311ba5
>
> Andrea
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2022-10-13 10:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-02 3:44 [PATCH] RISC-V: Add support for Ztso Palmer Dabbelt
2022-09-04 0:47 ` Richard Henderson
2022-09-16 12:52 ` Palmer Dabbelt
2022-09-17 8:02 ` Richard Henderson
2022-09-17 8:22 ` Palmer Dabbelt
2022-09-29 19:16 ` Dr. David Alan Gilbert
2022-10-02 21:20 ` Palmer Dabbelt
2022-10-03 8:44 ` Dr. David Alan Gilbert
2022-10-13 9:18 ` Andrea Parri
2022-10-13 9:59 ` Dr. David Alan Gilbert [this message]
2022-10-13 10:25 ` Andrea Parri
-- strict thread matches above, loose matches on Subject: below --
2022-09-02 3:43 Palmer Dabbelt
2022-09-02 6:39 ` Andreas Schwab
2022-09-16 14:09 ` Palmer Dabbelt
2022-09-02 6:50 ` Anup Patel
2022-09-16 14:15 ` Palmer Dabbelt
2022-09-16 10:00 ` Conor.Dooley
2022-09-16 14:09 ` Palmer Dabbelt
2022-09-16 14:13 ` Conor.Dooley
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=Y0fhi2/hcvb37uiO@work-vm \
--to=dgilbert@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=andrea@rivosinc.com \
--cc=palmer@rivosinc.com \
--cc=qemu-devel@nongnu.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.