Linux-ARM-Kernel Archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64/fpsimd: simplify sme_setup()
@ 2025-09-13  0:09 Yury Norov (NVIDIA)
  2025-09-16 21:13 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Yury Norov (NVIDIA) @ 2025-09-13  0:09 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Mark Rutland, Mark Brown,
	Ard Biesheuvel, linux-arm-kernel, linux-kernel
  Cc: Yury Norov (NVIDIA)

The function checks info->vq_map for emptiness right before calling
find_last_bit().

We can use the find_last_bit() output and save on bitmap_empty() call,
which is O(N).

Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
---
 arch/arm64/kernel/fpsimd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index c37f02d7194e..e3f8f51748bc 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -1265,6 +1265,8 @@ void __init sme_setup(void)
 	if (!system_supports_sme())
 		return;
 
+	min_bit = find_last_bit(info->vq_map, SVE_VQ_MAX);
+
 	/*
 	 * SME doesn't require any particular vector length be
 	 * supported but it does require at least one.  We should have
@@ -1272,9 +1274,8 @@ void __init sme_setup(void)
 	 * let's double check here.  The bitmap is SVE_VQ_MAP sized for
 	 * sharing with SVE.
 	 */
-	WARN_ON(bitmap_empty(info->vq_map, SVE_VQ_MAX));
+	WARN_ON(min_bit >= SVE_VQ_MAX);
 
-	min_bit = find_last_bit(info->vq_map, SVE_VQ_MAX);
 	info->min_vl = sve_vl_from_vq(__bit_to_vq(min_bit));
 
 	max_bit = find_first_bit(info->vq_map, SVE_VQ_MAX);
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] arm64/fpsimd: simplify sme_setup()
  2025-09-13  0:09 [PATCH] arm64/fpsimd: simplify sme_setup() Yury Norov (NVIDIA)
@ 2025-09-16 21:13 ` Will Deacon
  0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2025-09-16 21:13 UTC (permalink / raw)
  To: Catalin Marinas, Mark Rutland, Mark Brown, Ard Biesheuvel,
	linux-arm-kernel, linux-kernel, Yury Norov (NVIDIA)
  Cc: kernel-team, Will Deacon

On Fri, 12 Sep 2025 20:09:05 -0400, Yury Norov (NVIDIA) wrote:
> The function checks info->vq_map for emptiness right before calling
> find_last_bit().
> 
> We can use the find_last_bit() output and save on bitmap_empty() call,
> which is O(N).
> 
> 
> [...]

Applied to arm64 (for-next/misc), thanks!

[1/1] arm64/fpsimd: simplify sme_setup()
      https://git.kernel.org/arm64/c/19dd484cd19c

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-16 21:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-13  0:09 [PATCH] arm64/fpsimd: simplify sme_setup() Yury Norov (NVIDIA)
2025-09-16 21:13 ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).