Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <ajones@ventanamicro.com>
To: Drew Fustini <fustini@kernel.org>
Cc: "Palmer Dabbelt" <palmer@dabbelt.com>,
	"Paul Walmsley" <paul.walmsley@sifive.com>,
	"Alexandre Ghiti" <alex@ghiti.fr>,
	"Samuel Holland" <samuel.holland@sifive.com>,
	"Björn Töpel" <bjorn@rivosinc.com>,
	"Andy Chiu" <andybnac@gmail.com>,
	"Conor Dooley" <conor.dooley@microchip.com>,
	"Darius Rad" <darius@bluespec.com>,
	"Vivian Wang" <wangruikang@iscas.ac.cn>,
	"Florian Weimer" <fweimer@redhat.com>,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	"Drew Fustini" <dfustini@tenstorrent.com>
Subject: Re: [PATCH v3] riscv: Add sysctl to control discard of vstate on syscall entry
Date: Tue, 19 Aug 2025 19:20:15 -0500	[thread overview]
Message-ID: <967A5590-1B0E-4ADF-9947-E8F06CCF14D6@ventanamicro.com> (raw)
In-Reply-To: <aKUQXDh4u9xJx+jS@x1>

On August 19, 2025 7:01:32 PM CDT, Drew Fustini <fustini@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@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


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2025-08-20  0:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-19  9:40 [PATCH v3] riscv: Add sysctl to control discard of vstate on syscall entry Drew Fustini
2025-08-19 17:16 ` Andrew Jones
2025-08-20  0:01   ` Drew Fustini
2025-08-20  0:20     ` Andrew Jones [this message]
2025-08-20  1:31 ` Troy Mitchell
2025-08-20  1:35   ` Troy Mitchell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=967A5590-1B0E-4ADF-9947-E8F06CCF14D6@ventanamicro.com \
    --to=ajones@ventanamicro.com \
    --cc=alex@ghiti.fr \
    --cc=andybnac@gmail.com \
    --cc=bjorn@rivosinc.com \
    --cc=conor.dooley@microchip.com \
    --cc=darius@bluespec.com \
    --cc=dfustini@tenstorrent.com \
    --cc=fustini@kernel.org \
    --cc=fweimer@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=samuel.holland@sifive.com \
    --cc=wangruikang@iscas.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox