mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xu Lu <luxu.kernel@bytedance.com>
To: Andrea Parri <parri.andrea@gmail.com>
Cc: Guo Ren <guoren@kernel.org>,
	robh@kernel.org, krzk+dt@kernel.org,  conor+dt@kernel.org,
	paul.walmsley@sifive.com, palmer@dabbelt.com,
	 aou@eecs.berkeley.edu, alex@ghiti.fr, ajones@ventanamicro.com,
	 brs@rivosinc.com, devicetree@vger.kernel.org,
	linux-riscv@lists.infradead.org,  linux-kernel@vger.kernel.org,
	apw@canonical.com, joe@perches.com
Subject: Re: [External] Re: [PATCH v2 0/4] riscv: Add Zalasr ISA extension support
Date: Fri, 19 Sep 2025 16:22:07 +0800	[thread overview]
Message-ID: <CAPYmKFt7pDEDAb2yVyTfKCQh7iEM1VPNdq_vEMoYFDU2cavfGw@mail.gmail.com> (raw)
In-Reply-To: <aM0KBwkdPFD69oui@andrea>

Hi Andrea,

On Fri, Sep 19, 2025 at 3:45 PM Andrea Parri <parri.andrea@gmail.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

  reply	other threads:[~2025-09-19  8:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02  4:24 Xu Lu
2025-09-02  4:24 ` [PATCH v2 1/4] riscv: add ISA extension parsing for Zalasr Xu Lu
2025-09-02  4:24 ` [PATCH v2 2/4] dt-bindings: riscv: Add Zalasr ISA extension description Xu Lu
2025-09-02 19:46   ` Conor Dooley
2025-09-02  4:24 ` [PATCH v2 3/4] riscv: Instroduce Zalasr instructions Xu Lu
2025-09-02  4:24 ` [PATCH v2 4/4] riscv: Use Zalasr for smp_load_acquire/smp_store_release Xu Lu
2025-09-03  1:06   ` kernel test robot
2025-09-02 16:59 ` [PATCH v2 0/4] riscv: Add Zalasr ISA extension support Andrea Parri
2025-09-03 11:41   ` [External] " Xu Lu
2025-09-17  4:01   ` Guo Ren
2025-09-17  4:57     ` Guo Ren
2025-09-18 16:48     ` Guo Ren
2025-09-18 21:24       ` Andrea Parri
2025-09-20  5:59         ` Guo Ren
2025-09-19  3:18       ` [External] " Xu Lu
2025-09-19  7:45         ` Andrea Parri
2025-09-19  8:22           ` Xu Lu [this message]
2025-09-20  6:04         ` Guo Ren

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=CAPYmKFt7pDEDAb2yVyTfKCQh7iEM1VPNdq_vEMoYFDU2cavfGw@mail.gmail.com \
    --to=luxu.kernel@bytedance.com \
    --cc=ajones@ventanamicro.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=apw@canonical.com \
    --cc=brs@rivosinc.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=guoren@kernel.org \
    --cc=joe@perches.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=parri.andrea@gmail.com \
    --cc=paul.walmsley@sifive.com \
    --cc=robh@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®