[PATCH v2] riscv: Add sysctl to control discard of vstate during syscall

Florian Weimer fweimer at redhat.com
Sat Aug 9 01:40:46 PDT 2025


* Drew Fustini:

> 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
> sysctl knob is provided that controls whether the vector state is
> discarded in the syscall path:
>
> /proc/sys/abi/riscv_v_vstate_discard
>
> Valid values are:
>
> 0: Vector state is not always clobbered in all syscalls
> 1: Mandatory clobbering of vector state in all syscalls
>
> The initial state is controlled by CONFIG_RISCV_ISA_V_VSTATE_DISCARD.

Can this be put into the system call number instead, or make it specific
to some system calls in other ways?

I think C libraries can use this optimization for their system calls
(after adjusting the assembler clobbers) because the vector state is
caller-saved in the standard calling convention.  But there is backwards
compatibility impact for turning this on for the entire process.

Thanks,
Florian




More information about the linux-riscv mailing list