Re: [patch V6 01/11] rseq: Add fields and constants for time slice extension

From: Peter Zijlstra

Date: Mon Jan 19 2026 - 06:03:12 EST


On Mon, Jan 19, 2026 at 11:30:53AM +0100, Mathieu Desnoyers wrote:
> On 2026-01-19 05:21, Peter Zijlstra wrote:
> > On Sat, Jan 17, 2026 at 05:16:16PM +0100, Mathieu Desnoyers wrote:
> >
> > > My main concern is about the overhead of added system calls at thread
> > > creation. I recall that doing an additional rseq system call at thread
> > > creation was analyzed thoroughly for performance regressions at the
> > > libc level. I would not want to start requiring libc to issue a
> > > handful of additional prctl system calls per thread creation for no good
> > > reason.
> >
> > A wee something like so?
> >
> > That would allow registering rseq with RSEQ_FLAG_SLICE_EXT_DEFAULT_ON
> > set and if all the stars align, it will then have it on at the end.
>
> That's a very good step in the right direction. I just wonder how
> userspace is expected to learn that it runs on a kernel which
> accepts the RSEQ_FLAG_SLICE_EXT_DEFAULT_ON flag ?
>
> I think it could expect it when getauxval for AT_RSEQ_FEATURE_SIZE
> includes the slice ext field. This gives us a cheap way to know
> from userspace whether this new flag is supported or not.

struct rseq vs struct rseq_data. I don't think that slice field is
exposed on the user side of things.

I was thinking it could just try with the flag the firs time, and then
record if that worked or not and use the 'correct' value for all future
rseq calls.

> One nit below:
>
> [...]
> > - if (IS_ENABLED(CONFIG_RSEQ_SLICE_EXTENSION))
> > + if (IS_ENABLED(CONFIG_RSEQ_SLICE_EXTENSION)) {
> > rseqfl |= RSEQ_CS_FLAG_SLICE_EXT_AVAILABLE;
> > + if (rseq_slice_extension_enabled() &&
> > + flags & RSEQ_FLAG_SLICE_EXT_DEFAULT_ON)
>
> I think you want to surround flags & RSEQ_FLAG_SLICE_EXT_DEFAULT_ON with
> parentheses () to have the expected operator priority.

Moo, done (I added that rseq_slice_extension_enabled() test later).