public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Florian Weimer <fweimer@redhat.com>,
	Thomas Gleixner <tglx@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Boqun Feng <boqun.feng@gmail.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Prakash Sangappa <prakash.sangappa@oracle.com>,
	Madadi Vineeth Reddy <vineethr@linux.ibm.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-arch@vger.kernel.org, Randy Dunlap <rdunlap@infradead.org>,
	Ron Geva <rongevarg@gmail.com>, Waiman Long <longman@redhat.com>,
	"carlos@redhat.com" <carlos@redhat.com>,
	Michael Jeanson <mjeanson@efficios.com>
Subject: Re: [patch V6 01/11] rseq: Add fields and constants for time slice extension
Date: Mon, 19 Jan 2026 11:21:38 +0100	[thread overview]
Message-ID: <20260119102138.GQ830755@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <45fd706a-86be-42b8-879e-11bbe262e159@efficios.com>

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.

---

--- a/kernel/rseq.c
+++ b/kernel/rseq.c
@@ -424,7 +424,7 @@ SYSCALL_DEFINE4(rseq, struct rseq __user
 		return 0;
 	}
 
-	if (unlikely(flags))
+	if (unlikely(flags & ~(RSEQ_FLAG_SLICE_EXT_DEFAULT_ON)))
 		return -EINVAL;
 
 	if (current->rseq.usrptr) {
@@ -459,8 +459,12 @@ SYSCALL_DEFINE4(rseq, struct rseq __user
 	if (!access_ok(rseq, rseq_len))
 		return -EFAULT;
 
-	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)
+			rseqfl |= RSEQ_CS_FLAG_SLICE_EXT_ENABLED;
+	}
 
 	scoped_user_write_access(rseq, efault) {
 		/*
@@ -488,6 +492,10 @@ SYSCALL_DEFINE4(rseq, struct rseq __user
 	current->rseq.len = rseq_len;
 	current->rseq.sig = sig;
 
+#ifdef CONFIG_RSEQ_SLICE_EXTENSION
+	current->rseq.slice.state.enabled = !!(rseqfl & RSEQ_CS_FLAG_SLICE_EXT_ENABLED);
+#endif
+
 	/*
 	 * If rseq was previously inactive, and has just been
 	 * registered, ensure the cpu_id_start and cpu_id fields
--- a/include/uapi/linux/rseq.h
+++ b/include/uapi/linux/rseq.h
@@ -19,7 +19,8 @@ enum rseq_cpu_id_state {
 };
 
 enum rseq_flags {
-	RSEQ_FLAG_UNREGISTER = (1 << 0),
+	RSEQ_FLAG_UNREGISTER			= (1 << 0),
+	RSEQ_FLAG_SLICE_EXT_DEFAULT_ON		= (1 << 1),
 };
 
 enum rseq_cs_flags_bit {

  reply	other threads:[~2026-01-19 10:21 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15 16:52 [patch V6 00/11] rseq: Implement time slice extension mechanism Thomas Gleixner
2025-12-15 16:52 ` [patch V6 01/11] rseq: Add fields and constants for time slice extension Thomas Gleixner
2025-12-15 18:24   ` Thomas Gleixner
2025-12-16 14:36   ` Mathieu Desnoyers
2025-12-18 23:21     ` Thomas Gleixner
2026-01-07 21:11       ` Mathieu Desnoyers
2026-01-11 17:11         ` Thomas Gleixner
2026-01-13 23:45           ` Florian Weimer
2026-01-14 21:59             ` Thomas Gleixner
2026-01-17 16:16             ` Mathieu Desnoyers
2026-01-19 10:21               ` Peter Zijlstra [this message]
2026-01-19 10:30                 ` Mathieu Desnoyers
2026-01-19 11:03                   ` Peter Zijlstra
2026-01-19 11:10                     ` Mathieu Desnoyers
2026-01-19 11:27                       ` Peter Zijlstra
2026-01-19 10:46                 ` Florian Weimer
2026-01-17  9:36       ` Peter Zijlstra
2026-01-19 10:10   ` Peter Zijlstra
2025-12-15 16:52 ` [patch V6 02/11] rseq: Provide static branch for time slice extensions Thomas Gleixner
2025-12-15 18:24   ` Thomas Gleixner
2025-12-15 16:52 ` [patch V6 03/11] rseq: Add statistics " Thomas Gleixner
2025-12-15 18:24   ` Thomas Gleixner
2025-12-15 16:52 ` [patch V6 04/11] rseq: Add prctl() to enable " Thomas Gleixner
2025-12-15 18:24   ` Thomas Gleixner
2025-12-15 16:52 ` [patch V6 05/11] rseq: Implement sys_rseq_slice_yield() Thomas Gleixner
2025-12-15 18:24   ` Thomas Gleixner
2025-12-16 14:59   ` Mathieu Desnoyers
2025-12-15 16:52 ` [patch V6 06/11] rseq: Implement syscall entry work for time slice extensions Thomas Gleixner
2025-12-15 18:24   ` Thomas Gleixner
2025-12-16 15:05   ` Mathieu Desnoyers
2025-12-18 22:28     ` Thomas Gleixner
2025-12-18 22:30       ` Mathieu Desnoyers
2025-12-15 16:52 ` [patch V6 07/11] rseq: Implement time slice extension enforcement timer Thomas Gleixner
2025-12-15 18:24   ` Thomas Gleixner
2025-12-16  7:18   ` Randy Dunlap
2025-12-16 17:55     ` Prakash Sangappa
2025-12-16  8:26   ` [patch V6.1 " Thomas Gleixner
2025-12-16 15:13   ` [patch V6 " Mathieu Desnoyers
2025-12-18 15:05   ` Peter Zijlstra
2025-12-18 23:26     ` Thomas Gleixner
2025-12-19 10:05       ` Peter Zijlstra
2026-01-16 18:15         ` Peter Zijlstra
2026-01-18 10:46           ` Thomas Gleixner
2026-01-19 10:01             ` Peter Zijlstra
2025-12-18 15:18   ` Peter Zijlstra
2025-12-18 23:25     ` Thomas Gleixner
2026-01-17  9:57   ` Peter Zijlstra
2026-01-23 17:38     ` Prakash Sangappa
2026-01-23 17:41     ` Prakash Sangappa
2026-01-27 18:48       ` Peter Zijlstra
2025-12-15 16:52 ` [patch V6 08/11] rseq: Reset slice extension when scheduled Thomas Gleixner
2025-12-15 18:24   ` Thomas Gleixner
2025-12-16 15:17   ` Mathieu Desnoyers
2025-12-15 16:52 ` [patch V6 09/11] rseq: Implement rseq_grant_slice_extension() Thomas Gleixner
2025-12-15 18:24   ` Thomas Gleixner
2025-12-16 15:25   ` Mathieu Desnoyers
2025-12-18 23:28     ` Thomas Gleixner
2026-01-11 10:22       ` Thomas Gleixner
2025-12-15 16:52 ` [patch V6 10/11] entry: Hook up rseq time slice extension Thomas Gleixner
2025-12-15 18:24   ` Thomas Gleixner
2025-12-16 15:37   ` Mathieu Desnoyers
2025-12-19 11:07     ` Peter Zijlstra
2026-01-11 11:01       ` Thomas Gleixner
2026-01-17  9:51         ` Peter Zijlstra
2025-12-15 16:52 ` [patch V6 11/11] selftests/rseq: Implement time slice extension test Thomas Gleixner
2025-12-15 18:24   ` Thomas Gleixner
2025-12-15 18:24 ` [patch V6 00/11] rseq: Implement time slice extension mechanism Thomas Gleixner

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=20260119102138.GQ830755@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=arnd@arndb.de \
    --cc=bigeasy@linutronix.de \
    --cc=boqun.feng@gmail.com \
    --cc=carlos@redhat.com \
    --cc=corbet@lwn.net \
    --cc=fweimer@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mjeanson@efficios.com \
    --cc=paulmck@kernel.org \
    --cc=prakash.sangappa@oracle.com \
    --cc=rdunlap@infradead.org \
    --cc=rongevarg@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@kernel.org \
    --cc=vineethr@linux.ibm.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