[PATCH v2 0/1] Optimize Vector context restore on syscall

From: Andy Chiu

Date: Thu Apr 02 2026 - 00:51:54 EST


Accroding to the ABI, Vector registers are not preserved across a
syscall. Therefore, the kernel invalidates all V-reg at the entry of the
trap handler and marks the state dirty. This patch provide an
optimization such that the invalidation is performed only once before
returning back to the user space. Also by tracking this state,
specifically reserving VS_INITIAL for this optimized restore, we cut the
cost of saving and restoring V-reg at context switch for processes
calling syscalls.

---
Changelog v2: rebase on top of for-next

Andy Chiu (1):
riscv: vector: treat VS_INITIAL as discard

arch/riscv/include/asm/vector.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

--
2.53.0