From nobody Wed Feb 11 01:28:34 2026 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8557F4A5B05 for ; Wed, 21 Jan 2026 14:33:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769005983; cv=none; b=ZA1ns1GhQWKooIKkhtScCv7hm9tsmCwYu7QU7Z82Q1xUh/HFF5GhoGrCuk0sy1jGphiOjxODb+xU67L3egw6meLde3hpgzmVIrMf/et8c1aLutooP3G+X7OIkQKcTU1gjcrxw5XGnFkaHF4yynFymnUt67MKz4g67p1SSGRYPZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769005983; c=relaxed/simple; bh=r/XHxTP1SFkFube6S6fOcBRkOsLbQ/XJLZcfUO9aiFA=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=gQeUZqQ4OjGWBy/54YD2LsOGDfbT0QjuUGUjr4fOBCN3Q7CsYEbLsiee9tj3kCV5C2kI8zTzFqSiRp/f1XribkS/mK/3xJlR64RPAX1bxCmuBJA1KuHjqdQK1x2WM1Bhz45rUhhMwy9ZftL+krSsxXrqufFdG9LJAiDouDPm8k4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=pxWcp7KF; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="pxWcp7KF" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=aqy6q2PF4tmu1fKJosKubbHYefzcOUhLoPjupKeh2kQ=; b=pxWcp7KFGQlOVx4A9gazDajjXi fe399B6bWht4iNd8msFG6efDA4KDNPIqDlBYop3vKGMVuKLHB8p564yXHAV+YRRCj/f7OVpT0KJO0 AXgbmQBQz9ohuD/XK45CF8rb6EOhRIWxnZqIpuGqsWCOvA5pY9BcGZR0R7JC0GUiK0Hb2QrsIvkzP n+c+O3uhBJ/EKL/WKo3TV5N+QFZNOTxUb2gjzQWykWvu6Lb4eW15itB9cAcwXEg/1jBeXKXTDnqfF 7Yej8I06/TYhhPIEs7ewiasLSmHG8gAn9nKfct7IW1tKyqw8DyuJoSKOTyA5HN46gPxOIbmWA9sSP /lcKNt+Q==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1viZGF-0000000GCYI-0YDt; Wed, 21 Jan 2026 14:32:46 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 8D9383008E2; Wed, 21 Jan 2026 15:32:42 +0100 (CET) Message-ID: <20260121143207.923520192@infradead.org> User-Agent: quilt/0.68 Date: Wed, 21 Jan 2026 15:24:59 +0100 From: Peter Zijlstra 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 2/5] rseq: Move slice_ext_nsec to debugfs References: <20260121142457.242071831@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move changing the slice ext duration to debugfs, a sliglty less permanent interface. Signed-off-by: Peter Zijlstra (Intel) --- Documentation/admin-guide/sysctl/kernel.rst | 11 ---- Documentation/userspace-api/rseq.rst | 4 + kernel/rseq.c | 69 +++++++++++++++++++----= ----- 3 files changed, 51 insertions(+), 33 deletions(-) --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -1248,17 +1248,6 @@ reboot-cmd (SPARC only) ROM/Flash boot loader. Maybe to tell it what to do after rebooting. ??? =20 -rseq_slice_extension_nsec -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D - -A task can request to delay its scheduling if it is in a critical section -via the prctl(PR_RSEQ_SLICE_EXTENSION_SET) mechanism. This sets the maximum -allowed extension in nanoseconds before scheduling of the task is enforced. -Default value is 10000ns (10us). The possible range is 10000ns (10us) to -50000ns (50us). - -This value has a direct correlation to the worst case scheduling latency; -increment at your own risk. =20 sched_energy_aware =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- a/Documentation/userspace-api/rseq.rst +++ b/Documentation/userspace-api/rseq.rst @@ -79,7 +79,9 @@ slice extension by setting rseq::slice_c interrupted and the interrupt results in a reschedule request in the kernel, then the kernel can grant a time slice extension and return to userspace instead of scheduling out. The length of the extension is -determined by the ``rseq_slice_extension_nsec`` sysctl. +determined by debugfs:rseq/slice_ext_nsec. The default value is 10 usec; w= hich +is the minimum value. It can be incremented to 50 usecs, however doing so +can/will affect the minimum scheduling latency. =20 The kernel indicates the grant by clearing rseq::slice_ctrl::request and setting rseq::slice_ctrl::granted to 1. If there is a reschedule of the --- a/kernel/rseq.c +++ b/kernel/rseq.c @@ -222,12 +222,16 @@ static const struct file_operations debu .release =3D single_release, }; =20 +extern void rseq_slice_ext_init(struct dentry *root_dir); + static int __init rseq_debugfs_init(void) { struct dentry *root_dir =3D debugfs_create_dir("rseq", NULL); =20 debugfs_create_file("debug", 0644, root_dir, NULL, &debug_ops); rseq_stats_init(root_dir); + if (IS_ENABLED(CONFIG_RSEQ_SLICE_EXTENSIO)) + rseq_slice_ext_init(root_dir); return 0; } __initcall(rseq_debugfs_init); @@ -515,7 +519,9 @@ struct slice_timer { void *cookie; }; =20 -unsigned int rseq_slice_ext_nsecs __read_mostly =3D 10 * NSEC_PER_USEC; +static const unsigned int rseq_slice_ext_nsecs_min =3D 10 * NSEC_PER_USEC; +static const unsigned int rseq_slice_ext_nsecs_max =3D 50 * NSEC_PER_USEC; +unsigned int rseq_slice_ext_nsecs __read_mostly =3D rseq_slice_ext_nsecs_m= in; static DEFINE_PER_CPU(struct slice_timer, slice_timer); DEFINE_STATIC_KEY_TRUE(rseq_slice_extension_key); =20 @@ -761,30 +767,52 @@ SYSCALL_DEFINE0(rseq_slice_yield) return yielded; } =20 -#ifdef CONFIG_SYSCTL -static const unsigned int rseq_slice_ext_nsecs_min =3D 10 * NSEC_PER_USEC; -static const unsigned int rseq_slice_ext_nsecs_max =3D 50 * NSEC_PER_USEC; +#ifdef CONFIG_DEBUG_FS +static int rseq_slice_ext_show(struct seq_file *m, void *p) +{ + seq_printf(m, "%d\n", rseq_slice_ext_nsecs); + return 0; +} + +static ssize_t rseq_slice_ext_write(struct file *file, const char __user *= ubuf, + size_t count, loff_t *ppos) +{ + unsigned int nsecs; + + if (kstrtouint(ubuf, count, &nsecs)) + return -EINVAL; + + if (nsecs < rseq_slice_ext_nsecs_min) + return -ERANGE; + + if (nsecs > rseq_slice_ext_nsecs_max) + return -ERANGE; + + rseq_slice_ext_nsecs =3D nsecs; + + return count; +} =20 -static const struct ctl_table rseq_slice_ext_sysctl[] =3D { - { - .procname =3D "rseq_slice_extension_nsec", - .data =3D &rseq_slice_ext_nsecs, - .maxlen =3D sizeof(unsigned int), - .mode =3D 0644, - .proc_handler =3D proc_douintvec_minmax, - .extra1 =3D (unsigned int *)&rseq_slice_ext_nsecs_min, - .extra2 =3D (unsigned int *)&rseq_slice_ext_nsecs_max, - }, +static int rseq_slice_ext_open(struct inode *inode, struct file *file) +{ + return single_open(file, rseq_slice_ext_show, inode->i_private); +} + +static const struct file_operations slice_ext_ops =3D { + .open =3D rseq_slice_ext_open, + .read =3D seq_read, + .write =3D rseq_slice_ext_write, + .llseek =3D seq_lseek, + .release =3D single_release, }; =20 -static void rseq_slice_sysctl_init(void) +static void rseq_slice_ext_init(struct dentry *root_dir) { - if (rseq_slice_extension_enabled()) - register_sysctl_init("kernel", rseq_slice_ext_sysctl); + debugfs_create_file("slice_ext_nsec", 0644, root_dir, NULL, &slice_ext_op= s); } -#else /* CONFIG_SYSCTL */ -static inline void rseq_slice_sysctl_init(void) { } -#endif /* !CONFIG_SYSCTL */ +#else +static void rseq_slice_ext_init(struct dentry *root_dir) { } +#endif =20 static int __init rseq_slice_cmdline(char *str) { @@ -807,7 +835,6 @@ static int __init rseq_slice_init(void) hrtimer_setup(per_cpu_ptr(&slice_timer.timer, cpu), rseq_slice_expired, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED_HARD); } - rseq_slice_sysctl_init(); return 0; } device_initcall(rseq_slice_init);