[PATCH] riscv: Add sysctl to control discard of vstate during syscall
Vivian Wang
wangruikang at iscas.ac.cn
Wed Jul 23 14:55:54 PDT 2025
On 7/19/25 11:39, Drew Fustini wrote:
> From: Drew Fustini <dfustini at tenstorrent.com>
>
> Clobbering the vector registers can significantly increase system call
> latency for some implementations. To mitigate this performance impact, a
> policy mechanism is provided to administrators, distro maintainers, and
> developers to control vector state discard in the form of a sysctl knob:
So I had an idea: Is it possible to avoid repeatedly discarding the
state on every syscall by setting VS to Initial after discarding, and
avoiding discarding when VS is Initial? So:
if (VS == Clean || VS == Dirty) {
clobber;
VS = Initial;
}
This would avoid this problem with syscall-heavy user programs while
adding minimum overhead for everything else.
Note that I haven't checked closely on how VS = Initial is currently
used in Linux. This might require changes to vector init make the really
first-time initial state and the after-syscall initial state the same.
Or maybe I misunderstood entirely.
Vivian "dramforever" Wang
> /proc/sys/abi/riscv_v_vstate_discard
>
> Valid values are:
>
> 0: Do not discard vector state during syscall
> 1: Discard vector state during syscall
>
> The initial state is controlled by CONFIG_RISCV_ISA_V_VSTATE_DISCARD.
>
> Fixes: 9657e9b7d253 ("riscv: Discard vector state on syscalls")
> Signed-off-by: Drew Fustini <dfustini at tenstorrent.com>
> ---
> Documentation/arch/riscv/vector.rst | 15 +++++++++++++++
> arch/riscv/Kconfig | 10 ++++++++++
> arch/riscv/include/asm/vector.h | 4 ++++
> arch/riscv/kernel/vector.c | 16 +++++++++++++++-
> 4 files changed, 44 insertions(+), 1 deletion(-)
>
> [...]
More information about the linux-riscv
mailing list