* [PATCH v2] arm64/sve: Document that __SVE_VQ_MAX is much larger than needed
@ 2024-02-09 16:53 Mark Brown
2024-02-12 16:54 ` Dave Martin
2024-02-22 22:05 ` Catalin Marinas
0 siblings, 2 replies; 3+ messages in thread
From: Mark Brown @ 2024-02-09 16:53 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon
Cc: Dave Martin, linux-arm-kernel, linux-kernel, Mark Brown
__SVE_VQ_MAX is defined without comment as 512 but the actual
architectural maximum is 16, a substantial difference which might not
be obvious to readers especially given the several different units used
for specifying vector sizes in various contexts and the fact that it's
often used via macros. In an effort to minimise surprises for users who
might assume the value is the architectural maximum and use it to do
things like size allocations add a comment noting the difference, and
add a note for SVE_VQ_MAX to aid discoverability.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
Changes in v2:
- Use new wording mostly provided by Dave Martin.
- Reference __SVE_VQ_MAX comment near SVE_VQ_MAX define.
- Link to v1: https://lore.kernel.org/r/20240206-arm64-sve-vl-max-comment-v1-1-dddf16414412@kernel.org
---
| 11 +++++++++++
1 file changed, 11 insertions(+)
--git a/arch/arm64/include/uapi/asm/sve_context.h b/arch/arm64/include/uapi/asm/sve_context.h
index 754ab751b523..72aefc081061 100644
--- a/arch/arm64/include/uapi/asm/sve_context.h
+++ b/arch/arm64/include/uapi/asm/sve_context.h
@@ -13,6 +13,17 @@
#define __SVE_VQ_BYTES 16 /* number of bytes per quadword */
+/*
+ * Yes, __SVE_VQ_MAX is 512 QUADWORDS.
+ *
+ * To help ensure forward portability, this is much larger than the
+ * current maximum value defined by the SVE architecture. While arrays
+ * or static allocations can be sized based on this value, watch out!
+ * It will waste a surprisingly large amount of memory.
+ *
+ * Dynamic sizing based on the actual runtime vector length is likely to
+ * be preferable for most purposes.
+ */
#define __SVE_VQ_MIN 1
#define __SVE_VQ_MAX 512
---
base-commit: 54be6c6c5ae8e0d93a6c4641cb7528eb0b6ba478
change-id: 20240206-arm64-sve-vl-max-comment-64efa3f03625
Best regards,
--
Mark Brown <broonie@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] arm64/sve: Document that __SVE_VQ_MAX is much larger than needed
2024-02-09 16:53 [PATCH v2] arm64/sve: Document that __SVE_VQ_MAX is much larger than needed Mark Brown
@ 2024-02-12 16:54 ` Dave Martin
2024-02-22 22:05 ` Catalin Marinas
1 sibling, 0 replies; 3+ messages in thread
From: Dave Martin @ 2024-02-12 16:54 UTC (permalink / raw)
To: Mark Brown; +Cc: Catalin Marinas, Will Deacon, linux-arm-kernel, linux-kernel
On Fri, Feb 09, 2024 at 04:53:36PM +0000, Mark Brown wrote:
> __SVE_VQ_MAX is defined without comment as 512 but the actual
> architectural maximum is 16, a substantial difference which might not
> be obvious to readers especially given the several different units used
> for specifying vector sizes in various contexts and the fact that it's
> often used via macros. In an effort to minimise surprises for users who
> might assume the value is the architectural maximum and use it to do
> things like size allocations add a comment noting the difference, and
> add a note for SVE_VQ_MAX to aid discoverability.
>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
> Changes in v2:
> - Use new wording mostly provided by Dave Martin.
> - Reference __SVE_VQ_MAX comment near SVE_VQ_MAX define.
> - Link to v1: https://lore.kernel.org/r/20240206-arm64-sve-vl-max-comment-v1-1-dddf16414412@kernel.org
> ---
> arch/arm64/include/uapi/asm/sve_context.h | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/arch/arm64/include/uapi/asm/sve_context.h b/arch/arm64/include/uapi/asm/sve_context.h
> index 754ab751b523..72aefc081061 100644
> --- a/arch/arm64/include/uapi/asm/sve_context.h
> +++ b/arch/arm64/include/uapi/asm/sve_context.h
> @@ -13,6 +13,17 @@
>
> #define __SVE_VQ_BYTES 16 /* number of bytes per quadword */
>
> +/*
> + * Yes, __SVE_VQ_MAX is 512 QUADWORDS.
> + *
> + * To help ensure forward portability, this is much larger than the
> + * current maximum value defined by the SVE architecture. While arrays
> + * or static allocations can be sized based on this value, watch out!
> + * It will waste a surprisingly large amount of memory.
> + *
> + * Dynamic sizing based on the actual runtime vector length is likely to
> + * be preferable for most purposes.
> + */
> #define __SVE_VQ_MIN 1
> #define __SVE_VQ_MAX 512
Acked-by: Dave Martin <Dave.Martin@arm.com>
[...]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] arm64/sve: Document that __SVE_VQ_MAX is much larger than needed
2024-02-09 16:53 [PATCH v2] arm64/sve: Document that __SVE_VQ_MAX is much larger than needed Mark Brown
2024-02-12 16:54 ` Dave Martin
@ 2024-02-22 22:05 ` Catalin Marinas
1 sibling, 0 replies; 3+ messages in thread
From: Catalin Marinas @ 2024-02-22 22:05 UTC (permalink / raw)
To: Will Deacon, Mark Brown; +Cc: Dave Martin, linux-arm-kernel, linux-kernel
On Fri, 09 Feb 2024 16:53:36 +0000, Mark Brown wrote:
> __SVE_VQ_MAX is defined without comment as 512 but the actual
> architectural maximum is 16, a substantial difference which might not
> be obvious to readers especially given the several different units used
> for specifying vector sizes in various contexts and the fact that it's
> often used via macros. In an effort to minimise surprises for users who
> might assume the value is the architectural maximum and use it to do
> things like size allocations add a comment noting the difference, and
> add a note for SVE_VQ_MAX to aid discoverability.
>
> [...]
Applied to arm64 (for-next/misc), thanks!
[1/1] arm64/sve: Document that __SVE_VQ_MAX is much larger than needed
https://git.kernel.org/arm64/c/21eb468e9fc1
--
Catalin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-22 22:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-09 16:53 [PATCH v2] arm64/sve: Document that __SVE_VQ_MAX is much larger than needed Mark Brown
2024-02-12 16:54 ` Dave Martin
2024-02-22 22:05 ` Catalin Marinas
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®