From: Andrew Morton <akpm@linux-foundation.org>
To: Kuan-Wei Chiu <visitorckw@gmail.com>
Cc: paul.walmsley@sifive.com, palmer@dabbelt.com,
aou@eecs.berkeley.edu, alex@ghiti.fr,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
jserv@ccns.ncku.edu.tw, Yu-Chun Lin <eleanor15x@gmail.com>
Subject: Re: [PATCH v2 1/3] lib/math/gcd: Use static key to select implementation at runtime
Date: Wed, 4 Jun 2025 16:01:31 -0700 [thread overview]
Message-ID: <20250604160131.d00e8a3a2230a00f3818a3a1@linux-foundation.org> (raw)
In-Reply-To: <20250524155519.1142570-2-visitorckw@gmail.com>
On Sat, 24 May 2025 23:55:17 +0800 Kuan-Wei Chiu <visitorckw@gmail.com> wrote:
> On platforms like RISC-V, the compiler may generate hardware FFS
> instructions even if the underlying CPU does not actually support them.
> Currently, the GCD implementation is chosen at compile time based on
> CONFIG_CPU_NO_EFFICIENT_FFS, which can result in suboptimal behavior on
> such systems.
>
> Introduce a static key, efficient_ffs_key, to enable runtime selection
> between the binary GCD (using ffs) and the odd-even GCD implementation.
> This allows the kernel to default to the faster binary GCD when FFS is
> efficient, while retaining the ability to fall back when needed.
>
> ...
>
> @@ -54,6 +58,11 @@ unsigned long gcd(unsigned long a, unsigned long b)
> if (!a || !b)
> return r;
Both binary_gcd() and gcd() perform the above. Seems unnecessary?
I can merge this series if the riscv team are OK with it?
next prev parent reply other threads:[~2025-06-04 23:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-24 15:55 [PATCH v2 0/3] Optimize GCD performance on RISC-V by selecting implementation at runtime Kuan-Wei Chiu
2025-05-24 15:55 ` [PATCH v2 1/3] lib/math/gcd: Use static key to select " Kuan-Wei Chiu
2025-06-04 23:01 ` Andrew Morton [this message]
2025-05-24 15:55 ` [PATCH v2 2/3] riscv: Optimize gcd() code size when CONFIG_RISCV_ISA_ZBB is disabled Kuan-Wei Chiu
2025-05-24 15:55 ` [PATCH v2 3/3] riscv: Optimize gcd() performance on RISC-V without Zbb extension Kuan-Wei Chiu
2025-06-04 23:02 ` Andrew Morton
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=20250604160131.d00e8a3a2230a00f3818a3a1@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=eleanor15x@gmail.com \
--cc=jserv@ccns.ncku.edu.tw \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=visitorckw@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