[PATCH v10 0/2] arm64/sve: Performance improvements with SVE state saving
From: Mark Brown <broonie@kernel.org>
Date: 2026-07-03 12:46:37
Also in:
lkml
This series aims to improve our handling of SVE access traps and state clearing. As SVE deployment progresses both hardware and software actively using SVE is becoming more common. When a task is using SVE it faces additional costs, the floating point state we must track is larger and our syscall ABI requires that the extra state is cleared on every syscall. Users have measured these overheads and raised concerns about them. We can avoid these costs by reenabling SVE access traps and falling back to FPSIMD only mode but if we do this too often for tasks that are actively using SVE the cost of the access traps becomes prohibitive. Currently we attempt to balance the tradeoffs here by starting tasks with SVE disabled, enabling it on first use and then turning it off if we need to load state from memory while the task is in a syscall. This means that CPU bound tasks that do not regularly do blocking syscalls will rarely drop SVE while tasks that use a lot of SVE but do block in syscalls (eg, due to network or user interaction) will be much more likely to do and hence incur SVE access traps. I did some instrumentation which counted the number of SVE access traps and the number of times we loaded FPSIMD only register state for each task. Testing with Debian Bookworm this showed that during boot the overwhelming majority of tasks triggered another SVE access trap more than 50% of the time after loading FPSIMD only state with a substantial number near 100%, though some programs had a very small number of SVE accesses most likely from the dynamic linker. There were few tasks in the range 5-45%, most tasks either used SVE frequently or used it only a tiny proportion of times. As expected older distributions which do not have the SVE performance work available showed no SVE usage in general applications. For tasks with minimal SVE usage benchmarking with fp-pidbench on a system with 128 bit SVE shows an approximately 6% overhead on syscalls from having used SVE in the task, the overhead should be greater on a system with 256 bit SVE since the Z registers must be flushed as well as the P and FFR registers. The two patches here move to using a time based heuristic to decide when to reenable the SVE access trap, doing so after a second. This means that tasks actively using SVE which block in syscalls should see reduced or similar numbers of access traps, while CPU bound tasks that rarely use SVE will see the SVE syscall overhead removed after running for approximately a second, confirmed via fp-pidbench. The benchmarking here is all very much microbenchmarks so there are obviously some concerns on the system level impacts in actual use. Signed-off-by: Mark Brown <broonie@kernel.org> --- Changes in v10: - Rebase onto v7.2-rc1. - Link to v9: https://patch.msgid.link/20260518-arm64-sve-trap-mitigation-v9-0-9cc8fcd002fd@kernel.org Changes in v9: - Rebase onto v7.1-rc3. - Link to v8: https://patch.msgid.link/20260320-arm64-sve-trap-mitigation-v8-0-8bf116c8e360@kernel.org Changes in v8: - Rebase onto v7.0-rc3. - Add some benchmarking info from physical systems. - Add second patch that helps processes that stay on the CPU drop TIF_SVE. - Link to v7: https://lore.kernel.org/r/20240730-arm64-sve-trap-mitigation-v7-1-755e7e31bdd7@kernel.org (local) Changes in v7: - Rebase onto v6.11-rc1. - Only flush the predicate registers when loading FPSIMD state, Z will be flushed by loading the V registers. - Link to v6: https://lore.kernel.org/r/20240529-arm64-sve-trap-mitigation-v6-1-c2037be6aced@kernel.org (local) Changes in v6: - Rebase onto v6.10-rc1. - Link to v5: https://lore.kernel.org/r/20240405-arm64-sve-trap-mitigation-v5-1-126fe2515ef1@kernel.org (local) Changes in v5: - Rebase onto v6.9-rc1. - Use a timeout rather than number of state loads to decide when to reenable traps. - Link to v4: https://lore.kernel.org/r/20240122-arm64-sve-trap-mitigation-v4-1-54e0d78a3ae9@kernel.org (local) Changes in v4: - Rebase onto v6.8-rc1. - Link to v3: https://lore.kernel.org/r/20231113-arm64-sve-trap-mitigation-v3-1-4779c9382483@kernel.org (local) Changes in v3: - Rebase onto v6.7-rc1. - Link to v2: https://lore.kernel.org/r/20230913-arm64-sve-trap-mitigation-v2-1-1bdeff382171@kernel.org (local) Changes in v2: - Rebase onto v6.6-rc1. - Link to v1: https://lore.kernel.org/r/20230807-arm64-sve-trap-mitigation-v1-1-d92eed1d2855@kernel.org (local) --- Mark Brown (2): arm64/fpsimd: Suppress SVE access traps when loading FPSIMD state arm64/sve: Disable TIF_SVE on syscall once per second arch/arm64/include/asm/fpsimd.h | 15 ++++++++---- arch/arm64/include/asm/processor.h | 1 + arch/arm64/kernel/entry-common.c | 15 ++++++++++-- arch/arm64/kernel/fpsimd.c | 47 ++++++++++++++++++++++++++++++++------ 4 files changed, 64 insertions(+), 14 deletions(-) --- base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482 change-id: 20230807-arm64-sve-trap-mitigation-2e7e2663c849 Best regards, -- Mark Brown [off-list ref]