Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rseq: Move slice_ext_nsec to debugfs

Move changing the slice ext duration to debugfs, a sliglty less permanent
interface.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260121143207.923520192@infradead.org

+49 -35
-11
Documentation/admin-guide/sysctl/kernel.rst
··· 1248 1248 ROM/Flash boot loader. Maybe to tell it what to do after 1249 1249 rebooting. ??? 1250 1250 1251 - rseq_slice_extension_nsec 1252 - ========================= 1253 - 1254 - A task can request to delay its scheduling if it is in a critical section 1255 - via the prctl(PR_RSEQ_SLICE_EXTENSION_SET) mechanism. This sets the maximum 1256 - allowed extension in nanoseconds before scheduling of the task is enforced. 1257 - Default value is 10000ns (10us). The possible range is 10000ns (10us) to 1258 - 50000ns (50us). 1259 - 1260 - This value has a direct correlation to the worst case scheduling latency; 1261 - increment at your own risk. 1262 1251 1263 1252 sched_energy_aware 1264 1253 ==================
+3 -1
Documentation/userspace-api/rseq.rst
··· 79 79 interrupted and the interrupt results in a reschedule request in the 80 80 kernel, then the kernel can grant a time slice extension and return to 81 81 userspace instead of scheduling out. The length of the extension is 82 - determined by the ``rseq_slice_extension_nsec`` sysctl. 82 + determined by debugfs:rseq/slice_ext_nsec. The default value is 10 usec; which 83 + is the minimum value. It can be incremented to 50 usecs, however doing so 84 + can/will affect the minimum scheduling latency. 83 85 84 86 The kernel indicates the grant by clearing rseq::slice_ctrl::request and 85 87 setting rseq::slice_ctrl::granted to 1. If there is a reschedule of the
+46 -23
kernel/rseq.c
··· 123 123 } 124 124 #endif /* CONFIG_TRACEPOINTS */ 125 125 126 - #ifdef CONFIG_DEBUG_FS 127 126 #ifdef CONFIG_RSEQ_STATS 128 127 DEFINE_PER_CPU(struct rseq_stats, rseq_stats); 129 128 ··· 221 222 .release = single_release, 222 223 }; 223 224 225 + static void rseq_slice_ext_init(struct dentry *root_dir); 226 + 224 227 static int __init rseq_debugfs_init(void) 225 228 { 226 229 struct dentry *root_dir = debugfs_create_dir("rseq", NULL); 227 230 228 231 debugfs_create_file("debug", 0644, root_dir, NULL, &debug_ops); 229 232 rseq_stats_init(root_dir); 233 + if (IS_ENABLED(CONFIG_RSEQ_SLICE_EXTENSION)) 234 + rseq_slice_ext_init(root_dir); 230 235 return 0; 231 236 } 232 237 __initcall(rseq_debugfs_init); 233 - #endif /* CONFIG_DEBUG_FS */ 234 238 235 239 static bool rseq_set_ids(struct task_struct *t, struct rseq_ids *ids, u32 node_id) 236 240 { ··· 517 515 void *cookie; 518 516 }; 519 517 520 - unsigned int rseq_slice_ext_nsecs __read_mostly = 10 * NSEC_PER_USEC; 518 + static const unsigned int rseq_slice_ext_nsecs_min = 10 * NSEC_PER_USEC; 519 + static const unsigned int rseq_slice_ext_nsecs_max = 50 * NSEC_PER_USEC; 520 + unsigned int rseq_slice_ext_nsecs __read_mostly = rseq_slice_ext_nsecs_min; 521 521 static DEFINE_PER_CPU(struct slice_timer, slice_timer); 522 522 DEFINE_STATIC_KEY_TRUE(rseq_slice_extension_key); 523 523 ··· 765 761 return yielded; 766 762 } 767 763 768 - #ifdef CONFIG_SYSCTL 769 - static const unsigned int rseq_slice_ext_nsecs_min = 10 * NSEC_PER_USEC; 770 - static const unsigned int rseq_slice_ext_nsecs_max = 50 * NSEC_PER_USEC; 764 + static int rseq_slice_ext_show(struct seq_file *m, void *p) 765 + { 766 + seq_printf(m, "%d\n", rseq_slice_ext_nsecs); 767 + return 0; 768 + } 771 769 772 - static const struct ctl_table rseq_slice_ext_sysctl[] = { 773 - { 774 - .procname = "rseq_slice_extension_nsec", 775 - .data = &rseq_slice_ext_nsecs, 776 - .maxlen = sizeof(unsigned int), 777 - .mode = 0644, 778 - .proc_handler = proc_douintvec_minmax, 779 - .extra1 = (unsigned int *)&rseq_slice_ext_nsecs_min, 780 - .extra2 = (unsigned int *)&rseq_slice_ext_nsecs_max, 781 - }, 770 + static ssize_t rseq_slice_ext_write(struct file *file, const char __user *ubuf, 771 + size_t count, loff_t *ppos) 772 + { 773 + unsigned int nsecs; 774 + 775 + if (kstrtouint_from_user(ubuf, count, 10, &nsecs)) 776 + return -EINVAL; 777 + 778 + if (nsecs < rseq_slice_ext_nsecs_min) 779 + return -ERANGE; 780 + 781 + if (nsecs > rseq_slice_ext_nsecs_max) 782 + return -ERANGE; 783 + 784 + rseq_slice_ext_nsecs = nsecs; 785 + 786 + return count; 787 + } 788 + 789 + static int rseq_slice_ext_open(struct inode *inode, struct file *file) 790 + { 791 + return single_open(file, rseq_slice_ext_show, inode->i_private); 792 + } 793 + 794 + static const struct file_operations slice_ext_ops = { 795 + .open = rseq_slice_ext_open, 796 + .read = seq_read, 797 + .write = rseq_slice_ext_write, 798 + .llseek = seq_lseek, 799 + .release = single_release, 782 800 }; 783 801 784 - static void rseq_slice_sysctl_init(void) 802 + static void rseq_slice_ext_init(struct dentry *root_dir) 785 803 { 786 - if (rseq_slice_extension_enabled()) 787 - register_sysctl_init("kernel", rseq_slice_ext_sysctl); 804 + debugfs_create_file("slice_ext_nsec", 0644, root_dir, NULL, &slice_ext_ops); 788 805 } 789 - #else /* CONFIG_SYSCTL */ 790 - static inline void rseq_slice_sysctl_init(void) { } 791 - #endif /* !CONFIG_SYSCTL */ 792 806 793 807 static int __init rseq_slice_cmdline(char *str) 794 808 { ··· 829 807 hrtimer_setup(per_cpu_ptr(&slice_timer.timer, cpu), rseq_slice_expired, 830 808 CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED_HARD); 831 809 } 832 - rseq_slice_sysctl_init(); 833 810 return 0; 834 811 } 835 812 device_initcall(rseq_slice_init); 813 + #else 814 + static void rseq_slice_ext_init(struct dentry *root_dir) { } 836 815 #endif /* CONFIG_RSEQ_SLICE_EXTENSION */