From: Conor Dooley <conor@kernel.org>
To: Vivian Wang <wangruikang@iscas.ac.cn>
Cc: "Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Yury Norov" <yury.norov@gmail.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Paul Walmsley" <pjw@kernel.org>,
"Charlie Jenkins" <charlie@rivosinc.com>,
"Xiao Wang" <xiao.w.wang@intel.com>,
"Christoph Müllner" <christoph.muellner@vrull.eu>,
"Vivian Wang" <uwu@dram.page>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 0/5] riscv: Use __riscv_has_extension_{likely,unlikely}
Date: Sat, 11 Oct 2025 12:28:34 +0100 [thread overview]
Message-ID: <20251011-buffing-never-4911edc10600@spud> (raw)
In-Reply-To: <20251011-riscv-altn-helper-wip-v3-0-d40ddaa1985a@iscas.ac.cn>
[-- Attachment #1: Type: text/plain, Size: 2813 bytes --]
On Sat, Oct 11, 2025 at 07:35:42AM +0800, Vivian Wang wrote:
> There are about a dozen uses of asm goto in arch/riscv just to select
> between two code paths with the alternative mechanism. Convert them to
> the existing helpers __riscv_has_extension_{likely,unlikely}.
>
> In each case, I have preserved the existing code's choice of asm goto
> pattern while picking between "likely" and "unlikely", namely:
>
> ALTERNATIVE("j %l[no]", "nop", ...) -> "likely"
> ALTERNATIVE("nop", "j %l[yes]", ...) -> "unlikely"
>
> Since the helpers are just implementations of these patterns, the
> performance should be the same as before.
Can you explain why you're opting for the __ variant, instead of the one
without __? They should do the same thing in your cases, and resolve to
the alternative, since the non-alternative function call will be
unreachable and the assert is compiletime. There's currently no users of
the __ prefixed versions outside of other extension detection helpers, and
I think it should probably be kept that way if possible.
>
> These patches are also available at:
>
> https://github.com/dramforever/linux/tree/riscv/altn-helper/v2
>
> ---
> Changes in v3:
> - Rebased on riscv for-next
> - Resolve conflict, use ALT_RISCV_PAUSE() in moved lines
> - Link to v2: https://lore.kernel.org/r/20250821-riscv-altn-helper-wip-v2-0-9586fa702f78@iscas.ac.cn
>
> Changes in v2:
> - Cc'd authors who initially introduced the asm goto blocks
> - Use existing __riscv_has_extension_{likely,unlikely} instead
> - Remove bogus comment for Zbb being likely (checksum)
> - Restructured patch to minimize diff (bitops, hweight, cmpxchg)
> - Link to v1: https://lore.kernel.org/r/20250820-riscv-altn-helper-wip-v1-0-c3c626c1f7e6@iscas.ac.cn
>
> ---
> Vivian Wang (5):
> riscv: pgtable: Use __riscv_has_extension_unlikely
> riscv: checksum: Use __riscv_has_extension_likely
> riscv: hweight: Use __riscv_has_extension_likely
> riscv: bitops: Use __riscv_has_extension_likely
> riscv: cmpxchg: Use __riscv_has_extension_likely
>
> arch/riscv/include/asm/arch_hweight.h | 24 ++++++----------
> arch/riscv/include/asm/bitops.h | 32 ++++++---------------
> arch/riscv/include/asm/checksum.h | 13 +++------
> arch/riscv/include/asm/cmpxchg.h | 12 +++-----
> arch/riscv/include/asm/pgtable.h | 15 +++++-----
> arch/riscv/lib/csum.c | 53 ++++++++---------------------------
> arch/riscv/mm/pgtable.c | 22 +++++++--------
> 7 files changed, 53 insertions(+), 118 deletions(-)
> ---
> base-commit: cd5a0afbdf8033dc83786315d63f8b325bdba2fd
> change-id: 20250820-riscv-altn-helper-wip-00af3a552c37
>
> Best regards,
> --
> Vivian "dramforever" Wang
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2025-10-11 11:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-10 23:35 Vivian Wang
2025-10-10 23:35 ` [PATCH v3 1/5] riscv: pgtable: Use __riscv_has_extension_unlikely Vivian Wang
2025-10-10 23:35 ` [PATCH v3 2/5] riscv: checksum: Use __riscv_has_extension_likely Vivian Wang
2025-10-10 23:35 ` [PATCH v3 3/5] riscv: hweight: " Vivian Wang
2025-10-10 23:35 ` [PATCH v3 4/5] riscv: bitops: " Vivian Wang
2025-10-10 23:35 ` [PATCH v3 5/5] riscv: cmpxchg: " Vivian Wang
2025-10-10 23:38 ` [PATCH v3 0/5] riscv: Use __riscv_has_extension_{likely,unlikely} Vivian Wang
2025-10-11 11:28 ` Conor Dooley [this message]
2025-10-11 22:21 ` Vivian Wang
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=20251011-buffing-never-4911edc10600@spud \
--to=conor@kernel.org \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=charlie@rivosinc.com \
--cc=christoph.muellner@vrull.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux@rasmusvillemoes.dk \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=pjw@kernel.org \
--cc=uwu@dram.page \
--cc=wangruikang@iscas.ac.cn \
--cc=xiao.w.wang@intel.com \
--cc=yury.norov@gmail.com \
/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®