mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: tglx@linutronix.de, mathieu.desnoyers@efficios.com
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
	paulmck@kernel.org, boqun.feng@gmail.com, corbet@lwn.net,
	prakash.sangappa@oracle.com, vineethr@linux.ibm.com,
	kprateek.nayak@amd.com, rostedt@goodmis.org,
	bigeasy@linutronix.de, arnd@arndb.de, rdunlap@infradead.org,
	rongevarg@gmail.com, longman@redhat.com
Subject: [PATCH 1/5] rseq: Allow registering RSEQ with slice extension
Date: Wed, 21 Jan 2026 15:24:58 +0100	[thread overview]
Message-ID: <20260121143207.814193010@infradead.org> (raw)
In-Reply-To: <20260121142457.242071831@infradead.org>

Since glibc cares about the number of syscalls required to initialize a new
thread, allow initializing rseq with slice extension on. This avoids having to
do another prctl().

Requested-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 include/uapi/linux/rseq.h |    3 ++-
 kernel/rseq.c             |   12 ++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

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



  reply	other threads:[~2026-01-21 14:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-21 14:24 [PATCH 0/5] rseq: Various slice-ext changes Peter Zijlstra
2026-01-21 14:24 ` Peter Zijlstra [this message]
2026-01-22 10:15   ` [tip: sched/core] rseq: Allow registering RSEQ with slice extension tip-bot2 for Peter Zijlstra
2026-01-21 14:24 ` [PATCH 2/5] rseq: Move slice_ext_nsec to debugfs Peter Zijlstra
2026-01-21 14:50   ` Thomas Weißschuh
2026-01-21 14:56     ` Peter Zijlstra
2026-01-21 15:15     ` Peter Zijlstra
2026-01-22 10:15   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2026-01-21 14:25 ` [PATCH 3/5] rseq: Lower default slice extension Peter Zijlstra
2026-01-22 10:15   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2026-01-21 14:25 ` [PATCH 4/5] hrtimer: Fix trace oddity Peter Zijlstra
2026-01-22 10:15   ` [tip: sched/core] " tip-bot2 for Thomas Gleixner
2026-01-21 14:25 ` [PATCH 5/5] selftests/rseq: Add rseq slice histogram script Peter Zijlstra
2026-01-22 10:15   ` [tip: sched/core] " tip-bot2 for Peter Zijlstra

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=20260121143207.814193010@infradead.org \
    --to=peterz@infradead.org \
    --cc=arnd@arndb.de \
    --cc=bigeasy@linutronix.de \
    --cc=boqun.feng@gmail.com \
    --cc=corbet@lwn.net \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mathieu.desnoyers@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@linutronix.de \
    --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

all inboxes | Powered by JetHome®