[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250604160131.d00e8a3a2230a00f3818a3a1@linux-foundation.org>
Date: Wed, 4 Jun 2025 16:01:31 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Kuan-Wei Chiu <visitorckw@...il.com>
Cc: paul.walmsley@...ive.com, palmer@...belt.com, aou@...s.berkeley.edu,
alex@...ti.fr, linux-riscv@...ts.infradead.org,
linux-kernel@...r.kernel.org, jserv@...s.ncku.edu.tw, Yu-Chun Lin
<eleanor15x@...il.com>
Subject: Re: [PATCH v2 1/3] lib/math/gcd: Use static key to select
implementation at runtime
On Sat, 24 May 2025 23:55:17 +0800 Kuan-Wei Chiu <visitorckw@...il.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?
Powered by blists - more mailing lists