mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vivian Wang <wangruikang@iscas.ac.cn>
To: Conor Dooley <conor@kernel.org>
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>,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 0/5] riscv: Use __riscv_has_extension_{likely,unlikely}
Date: Sun, 12 Oct 2025 06:21:16 +0800	[thread overview]
Message-ID: <60069cae-64fb-45de-8b74-e9a42a4b01b6@iscas.ac.cn> (raw)
In-Reply-To: <20251011-buffing-never-4911edc10600@spud>


On 10/11/25 19:28, Conor Dooley wrote:
> 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.

I agree that it's preferable to use the non-__ functions. I'll do that
in the next version.

The only real reason I had used the __ versions is so that it would be
equivalent to existing code, although as you said these should be
equivalent since the uses are already guarded behind.

The "pgtable" code currently isn't guarded behind CONFIG_ALTERNATIVE,
although now that I think about it, it should actually be preferable to
do a runtime check than to do a TLB cleaning, so that one should
probably be non-__ as well.

Thanks,
Vivian "dramforever" Wang


      reply	other threads:[~2025-10-11 22:21 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
2025-10-11 22:21   ` Vivian Wang [this message]

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=60069cae-64fb-45de-8b74-e9a42a4b01b6@iscas.ac.cn \
    --to=wangruikang@iscas.ac.cn \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=charlie@rivosinc.com \
    --cc=christoph.muellner@vrull.eu \
    --cc=conor@kernel.org \
    --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=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®