arm64/fpsimd: Add interface for kernel use of SVE and SME
PATCH v3 1/1 arm64/fpsimd: Add interface for kernel use of SVE and SME
We currently support in kernel use of FPSIMD via the kernel_neon_begin() and kernel_neon_end() interface but there is no corresponding interface for SVE or SME. Given that SVE hardware is now becoming widely available there is interest in using these more modern floating point instruction sets for in kernel applications let's add an interface which allows them to be selected in addition to FPSIMD.
The sharing of registers and code means that using kernel_neon_begin() is actually doing most of the setup required, the only problem is that we are not configuring the vector length so any SVE or SME code would just use whatever vector length is configured in the hardware potentially leading to uneven performance on systems which support multiple vector lengths. Add a new kernel_fp_begin()/end() interface which allows the caller to flag if it will use SVE or SME and initialises the vector length if requested.
We allow simultaneous specification of multiple extensions since it is possible that a user may wish to mix them in a single algorithm, there is no cost to allowing this.
---
This patch is mainly published so that people working on implmenenting in kernel SVE or SME have something to reference, I'm not expecting it to be merged until we have an algorithm we want to merge. For now the main thing is avoiding having to explain the considerations for vector length configuration repeatedly.
v3:
- Rebase onto v6.2-rc1.
- Fix build with SVE and !SME on clang.
- Make symbol _GPL.
v2:
- Check for system_supports_sme() for setting the SME VL.
--- arch/arm64/include/asm/fpsimd.h | 7 ++++++ arch/arm64/kernel/fpsimd.c | 47 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)
arch/arm64/include/asm/fpsimd.h +7 -0
@@ -44,6 +44,13 @@*/ #define SME_VQ_MAX 16 +#define KERNEL_FP_FPSIMD 1 +#define KERNEL_FP_SVE 2 +#define KERNEL_FP_SME 4 + +void kernel_fp_begin (unsigned int flags); +void kernel_fp_end (void ); +struct task_struct ;extern void fpsimd_save_state (struct user_fpsimd_state *state);
arch/arm64/kernel/fpsimd.c +47 -0
53 lines not on this page · raw message
---
base-commit: 1b929c02afd37871d5afb9d498426f83432e71c2
change-id: 20221208-arm64-kernel-sve-sme-8b835ce7581b
Best regards,
Signature · 6 lines
Mark Brown <[email protected]> _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel