]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rseq: Provide static branch for time slice extensions
authorThomas Gleixner <tglx@linutronix.de>
Mon, 15 Dec 2025 16:52:06 +0000 (17:52 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 22 Jan 2026 10:11:16 +0000 (11:11 +0100)
Guard the time slice extension functionality with a static key, which can
be disabled on the kernel command line.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20251215155708.733429292@linutronix.de
Documentation/admin-guide/kernel-parameters.txt
include/linux/rseq_entry.h
kernel/rseq.c

index a8d0afde7f85a506b827ae31d48fc5d9dbabc095..f2348bca36a1696ff8cabdf3fb20f0fae16fc405 100644 (file)
@@ -6600,6 +6600,11 @@ Kernel parameters
 
        rootflags=      [KNL] Set root filesystem mount option string
 
+       rseq_slice_ext= [KNL] RSEQ based time slice extension
+                       Format: boolean
+                       Control enablement of RSEQ based time slice extension.
+                       Default is 'on'.
+
        initramfs_options= [KNL]
                         Specify mount options for for the initramfs mount.
 
index a36b472627dec83a9a196eb33b83e8d39061ffbe..d0ec4714ffd61f65ba4d45c32d0c66ce74533a57 100644 (file)
@@ -75,6 +75,17 @@ DECLARE_STATIC_KEY_MAYBE(CONFIG_RSEQ_DEBUG_DEFAULT_ENABLE, rseq_debug_enabled);
 #define rseq_inline __always_inline
 #endif
 
+#ifdef CONFIG_RSEQ_SLICE_EXTENSION
+DECLARE_STATIC_KEY_TRUE(rseq_slice_extension_key);
+
+static __always_inline bool rseq_slice_extension_enabled(void)
+{
+       return static_branch_likely(&rseq_slice_extension_key);
+}
+#else /* CONFIG_RSEQ_SLICE_EXTENSION */
+static inline bool rseq_slice_extension_enabled(void) { return false; }
+#endif /* !CONFIG_RSEQ_SLICE_EXTENSION */
+
 bool rseq_debug_update_user_cs(struct task_struct *t, struct pt_regs *regs, unsigned long csaddr);
 bool rseq_debug_validate_ids(struct task_struct *t);
 
index 07c324d5a201ad0713459dda2b01f85a6bbf091f..bf75268580ef2ff928d455f6049c3b18030b2a48 100644 (file)
@@ -483,3 +483,20 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len, int, flags, u32
 efault:
        return -EFAULT;
 }
+
+#ifdef CONFIG_RSEQ_SLICE_EXTENSION
+DEFINE_STATIC_KEY_TRUE(rseq_slice_extension_key);
+
+static int __init rseq_slice_cmdline(char *str)
+{
+       bool on;
+
+       if (kstrtobool(str, &on))
+               return 0;
+
+       if (!on)
+               static_branch_disable(&rseq_slice_extension_key);
+       return 1;
+}
+__setup("rseq_slice_ext=", rseq_slice_cmdline);
+#endif /* CONFIG_RSEQ_SLICE_EXTENSION */