[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPYmKFt7pDEDAb2yVyTfKCQh7iEM1VPNdq_vEMoYFDU2cavfGw@mail.gmail.com>
Date: Fri, 19 Sep 2025 16:22:07 +0800
From: Xu Lu <luxu.kernel@...edance.com>
To: Andrea Parri <parri.andrea@...il.com>
Cc: Guo Ren <guoren@...nel.org>, robh@...nel.org, krzk+dt@...nel.org,
conor+dt@...nel.org, paul.walmsley@...ive.com, palmer@...belt.com,
aou@...s.berkeley.edu, alex@...ti.fr, ajones@...tanamicro.com,
brs@...osinc.com, devicetree@...r.kernel.org, linux-riscv@...ts.infradead.org,
linux-kernel@...r.kernel.org, apw@...onical.com, joe@...ches.com
Subject: Re: [External] Re: [PATCH v2 0/4] riscv: Add Zalasr ISA extension support
Hi Andrea,
On Fri, Sep 19, 2025 at 3:45 PM Andrea Parri <parri.andrea@...il.com> wrote:
>
> > The existing implementation of spin_unlock, when followed by
> > spin_lock, is equal to 'FENCE rw, rw' for operations before
>
> This is not true without Zacas, that is, when using LR/SC: write-to-read
> remains unordered in that case.
Yes. Thanks for your corrections.
The LR/SC here, when Zacas or Zabha is not implemented, will behaves like:
fence rw, w
sd
lr.w
sc,w
fence r, rw
The 'fence rw, w' ensures the order of operations before itself and 'sc.w'.
The 'fence r, rw' ensures the order of operations after itself and 'lr.w'.
The operations between 'lr.w' and 'sc.w' are as few as possible and
cannot contain load or stores as is said in section 13.3 of riscv
unpriv spec:
"The dynamic code executed between the LR and SC instructions can only
contain instructions from the base ''I'' instruction set, excluding
loads, stores, backward jumps, taken backward branches, JALR, FENCE,
and SYSTEM instructions."
So in summary, though it does not provide 'fence rw, rw' semantics,
there is limited space available for the CPU to reorder.
And, still, I think calling spin_unlock immediately followed by
spin_lock on the same core is much rarer than calling spin_unlock on
one core and spin_lock on another core.
Best regards,
Xu Lu
>
> Andrea
Powered by blists - more mailing lists