Re: [PATCH v3] riscv: Add sysctl to control discard of vstate on syscall entry
Andrew Jones
ajones at ventanamicro.com
Tue Aug 19 17:20:15 PDT 2025
On August 19, 2025 7:01:32 PM CDT, Drew Fustini <fustini at kernel.org> wrote:
>On Tue, Aug 19, 2025 at 12:16:02PM -0500, Andrew Jones wrote:
>> On Tue, Aug 19, 2025 at 02:40:21AM -0700, Drew Fustini wrote:
>> > From: Drew Fustini <dfustini at tenstorrent.com>
>> >
>> > Vector registers are always clobbered in the syscall entry path to
>> > enforce the documented ABI that vector state is not preserved across
>> > syscalls. However, this operation can be slow on some RISC-V cores.
>> > To mitigate this performance impact, add a sysctl knob to control
>> > whether vector state is discarded in the syscall entry path:
>> >
>> > /proc/sys/abi/riscv_v_vstate_discard
>> >
>> > Valid values are:
>> >
>> > 0: Vector state is not intentionally clobbered when entering a syscall
>> > 1: Vector state is always clobbered when entering a syscall
>> >
>> > The initial state is controlled by CONFIG_RISCV_ISA_V_VSTATE_DISCARD.
>>
>> I'm in favor of the clobbering being off by default and creating a knob
>> to enable it for debug purposes, but I'm not sure we need the config. I
>> think it's reasonable for systems that need the discard behavior to add
>> a sysctl toggle to their early init. The config may complicate the
>> documentation needed for user recommendations and potentially generate
>> confusion when moving from one system to another since defaults could
>> be flipped.
>
>If I dropped CONFIG_RISCV_ISA_V_VSTATE_DISCARD, then are you thinking
>that riscv_v_vstate_discard_ctl would be initialized to 0 instead?
>
Yes, discard off by default.
Thanks,
drew
>I would be okay with that as it defaults to the clobbering being off.
>Hopefully, Palmer will chime in on whether setting the sysctl in an
>init script would be acceptable. He told me that he does want to retain
>the strict clobbering behavior on his tester machine.
>
>Thanks,
>Drew
More information about the linux-riscv
mailing list