From: Guo Ren <guoren@kernel.org>
To: Andrea Parri <parri.andrea@gmail.com>
Cc: Xu Lu <luxu.kernel@bytedance.com>,
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: [PATCH v2 0/4] riscv: Add Zalasr ISA extension support
Date: Wed, 17 Sep 2025 00:57:21 -0400 [thread overview]
Message-ID: <aMo/sQR80i7GbpAF@gmail.com> (raw)
In-Reply-To: <aMoyntAydNMtcl+3@gmail.com>
On Wed, Sep 17, 2025 at 12:01:34AM -0400, Guo Ren wrote:
> On Tue, Sep 02, 2025 at 06:59:15PM +0200, Andrea Parri wrote:
> > > Xu Lu (4):
> > > riscv: add ISA extension parsing for Zalasr
> > > dt-bindings: riscv: Add Zalasr ISA extension description
> > > riscv: Instroduce Zalasr instructions
> > > riscv: Use Zalasr for smp_load_acquire/smp_store_release
> >
> > Informally put, our (Linux) memory consistency model specifies that any
> > sequence
> >
> > spin_unlock(s);
> > spin_lock(t);
> >
> > behaves "as it provides at least FENCE.TSO ordering between operations
> > which precede the UNLOCK+LOCK sequence and operations which follow the
> > sequence". Unless I missing something, the patch set in question breaks
> > such ordering property (on RISC-V): for example, a "release" annotation,
> > .RL (as in spin_unlock() -> smp_store_release(), after patch #4) paired
> > with an "acquire" fence, FENCE R,RW (as could be found in spin_lock() ->
> > atomic_try_cmpxchg_acquire()) do not provide the specified property.
> >
> > I _think some solutions to the issue above include:
> >
> > a) make sure an .RL annotation is always paired with an .AQ annotation
> > and viceversa an .AQ annotation is paired with an .RL annotation
> > (this approach matches the current arm64 approach/implementation);
> >
> > b) on the opposite direction, always pair FENCE R,RW (or occasionally
> > FENCE R,R) with FENCE RW,W (this matches the current approach/the
> > current implementation within riscv);
> >
> > c) mix the previous two solutions (resp., annotations and fences), but
> > make sure to "upgrade" any releases to provide (insert) a FENCE.TSO.
> I prefer option c) at first, it has fewer modification and influence.
>
> asm volatile(ALTERNATIVE("fence rw, w;\t\nsb %0, 0(%1)\t\n", \
> - SB_RL(%0, %1) "\t\nnop\t\n", \
> + SB_RL(%0, %1) "\t\n fence.tso;\t\n", \
"fence rw, rw;\t\nsb %0, 0(%1)\t\n", \
How about enhance fence rw, rw? It's a bit more stronger than .tso.
0, RISCV_ISA_EXT_ZALASR, 1) \
> : : "r" (v), "r" (p) : "memory"); \
>
> I didn't object option a), and I think it could be done in the future.
> Acquire Zalasr extension step by step.
>
> >
> > (a) would align RISC-V and ARM64 (which is a good thing IMO), though it
> > is probably the most invasive approach among the three approaches above
> > (requiring certain changes to arch/riscv/include/asm/{cmpxchg,atomic}.h,
> > which are already relatively messy due to the various ZABHA plus ZACAS
> > switches). Overall, I'm not too exited at the idea of reviewing any of
> > those changes, but if the community opts for it, I'll almost definitely
> > take a closer look with due calm. ;-)
> >
> > Andrea
> >
> > _______________________________________________
> > linux-riscv mailing list
> > linux-riscv@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-riscv
> >
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Guo Ren <guoren@kernel.org>
To: Andrea Parri <parri.andrea@gmail.com>
Cc: Xu Lu <luxu.kernel@bytedance.com>,
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: [PATCH v2 0/4] riscv: Add Zalasr ISA extension support
Date: Wed, 17 Sep 2025 00:57:21 -0400 [thread overview]
Message-ID: <aMo/sQR80i7GbpAF@gmail.com> (raw)
In-Reply-To: <aMoyntAydNMtcl+3@gmail.com>
On Wed, Sep 17, 2025 at 12:01:34AM -0400, Guo Ren wrote:
> On Tue, Sep 02, 2025 at 06:59:15PM +0200, Andrea Parri wrote:
> > > Xu Lu (4):
> > > riscv: add ISA extension parsing for Zalasr
> > > dt-bindings: riscv: Add Zalasr ISA extension description
> > > riscv: Instroduce Zalasr instructions
> > > riscv: Use Zalasr for smp_load_acquire/smp_store_release
> >
> > Informally put, our (Linux) memory consistency model specifies that any
> > sequence
> >
> > spin_unlock(s);
> > spin_lock(t);
> >
> > behaves "as it provides at least FENCE.TSO ordering between operations
> > which precede the UNLOCK+LOCK sequence and operations which follow the
> > sequence". Unless I missing something, the patch set in question breaks
> > such ordering property (on RISC-V): for example, a "release" annotation,
> > .RL (as in spin_unlock() -> smp_store_release(), after patch #4) paired
> > with an "acquire" fence, FENCE R,RW (as could be found in spin_lock() ->
> > atomic_try_cmpxchg_acquire()) do not provide the specified property.
> >
> > I _think some solutions to the issue above include:
> >
> > a) make sure an .RL annotation is always paired with an .AQ annotation
> > and viceversa an .AQ annotation is paired with an .RL annotation
> > (this approach matches the current arm64 approach/implementation);
> >
> > b) on the opposite direction, always pair FENCE R,RW (or occasionally
> > FENCE R,R) with FENCE RW,W (this matches the current approach/the
> > current implementation within riscv);
> >
> > c) mix the previous two solutions (resp., annotations and fences), but
> > make sure to "upgrade" any releases to provide (insert) a FENCE.TSO.
> I prefer option c) at first, it has fewer modification and influence.
>
> asm volatile(ALTERNATIVE("fence rw, w;\t\nsb %0, 0(%1)\t\n", \
> - SB_RL(%0, %1) "\t\nnop\t\n", \
> + SB_RL(%0, %1) "\t\n fence.tso;\t\n", \
"fence rw, rw;\t\nsb %0, 0(%1)\t\n", \
How about enhance fence rw, rw? It's a bit more stronger than .tso.
0, RISCV_ISA_EXT_ZALASR, 1) \
> : : "r" (v), "r" (p) : "memory"); \
>
> I didn't object option a), and I think it could be done in the future.
> Acquire Zalasr extension step by step.
>
> >
> > (a) would align RISC-V and ARM64 (which is a good thing IMO), though it
> > is probably the most invasive approach among the three approaches above
> > (requiring certain changes to arch/riscv/include/asm/{cmpxchg,atomic}.h,
> > which are already relatively messy due to the various ZABHA plus ZACAS
> > switches). Overall, I'm not too exited at the idea of reviewing any of
> > those changes, but if the community opts for it, I'll almost definitely
> > take a closer look with due calm. ;-)
> >
> > Andrea
> >
> > _______________________________________________
> > linux-riscv mailing list
> > linux-riscv@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-riscv
> >
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
>
next prev parent reply other threads:[~2025-09-17 4:57 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-02 4:24 [PATCH v2 0/4] riscv: Add Zalasr ISA extension support Xu Lu
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 ` Xu Lu
2025-09-02 4:24 ` [PATCH v2 2/4] dt-bindings: riscv: Add Zalasr ISA extension description Xu Lu
2025-09-02 4:24 ` Xu Lu
2025-09-02 19:46 ` Conor Dooley
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 ` 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-02 4:24 ` Xu Lu
2025-09-03 1:06 ` kernel test robot
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-02 16:59 ` Andrea Parri
2025-09-03 11:41 ` [External] " Xu Lu
2025-09-03 11:41 ` Xu Lu
2025-09-17 4:01 ` Guo Ren
2025-09-17 4:01 ` Guo Ren
2025-09-17 4:57 ` Guo Ren [this message]
2025-09-17 4:57 ` Guo Ren
2025-09-18 16:48 ` Guo Ren
2025-09-18 16:48 ` Guo Ren
2025-09-18 21:24 ` Andrea Parri
2025-09-18 21:24 ` Andrea Parri
2025-09-20 5:59 ` Guo Ren
2025-09-20 5:59 ` Guo Ren
2025-09-19 3:18 ` [External] " Xu Lu
2025-09-19 3:18 ` Xu Lu
2025-09-19 7:45 ` Andrea Parri
2025-09-19 7:45 ` Andrea Parri
2025-09-19 8:22 ` Xu Lu
2025-09-19 8:22 ` Xu Lu
2025-09-20 6:04 ` Guo Ren
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=aMo/sQR80i7GbpAF@gmail.com \
--to=guoren@kernel.org \
--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=joe@perches.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=luxu.kernel@bytedance.com \
--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 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.