linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Drew Fustini <fustini@kernel.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: "Paul Walmsley" <paul.walmsley@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.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>,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	"Drew Fustini" <dfustini@tenstorrent.com>
Subject: Re: [PATCH v2] riscv: Add sysctl to control discard of vstate during syscall
Date: Sat, 9 Aug 2025 14:23:49 -0700	[thread overview]
Message-ID: <aJe8ZW5LEtBK7Jmj@x1> (raw)
In-Reply-To: <lhuo6so7ur5.fsf@oldenburg.str.redhat.com>

On Sat, Aug 09, 2025 at 10:40:46AM +0200, Florian Weimer wrote:
> * Drew Fustini:
> 
> > From: Drew Fustini <dfustini@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?

Do you mean the control the initial state of the sysctl, or not having a
sysctl for discard behavior at all?

> 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.

The focus I have right now is allowing users to avoid the delay in
syscall entry on implementations where clobbering is slow. Palmer had
mentioned in my v1 [1] that he has 'a patch out for GCC that enables a
system-wide vector ABI, but I don't have time to test/benchmark it so 
it's kind of hard to justify'. It seems like creating a new ABI where
the vector registers are preserved across syscalls could be useful, but
I think it would be best to handle that possiblity later on.

Thanks,
Drew

[1] https://lore.kernel.org/linux-riscv/mhng-E49DDC7D-A330-4626-A122-4146AADDBB33@Palmers-Mini.rwc.dabbelt.com/

  reply	other threads:[~2025-08-09 21:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06 14:03 [PATCH v2] riscv: Add sysctl to control discard of vstate during syscall Drew Fustini
2025-08-08 12:36 ` Darius Rad
2025-08-09  3:58   ` Vivian Wang
2025-08-09  7:54     ` Drew Fustini
2025-08-10  9:52       ` Vivian Wang
2025-08-12  5:46         ` Drew Fustini
2025-08-09 13:23     ` Darius Rad
2025-08-09  8:40 ` Florian Weimer
2025-08-09 21:23   ` Drew Fustini [this message]
2025-08-10  7:45     ` Florian Weimer
2025-08-11 20:36       ` Drew Fustini
2025-08-12  8:03         ` Florian Weimer

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=aJe8ZW5LEtBK7Jmj@x1 \
    --to=fustini@kernel.org \
    --cc=alex@ghiti.fr \
    --cc=andybnac@gmail.com \
    --cc=bjorn@rivosinc.com \
    --cc=conor.dooley@microchip.com \
    --cc=dfustini@tenstorrent.com \
    --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 \
    /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;
as well as URLs for NNTP newsgroup(s).