@@ -123,7 +123,6 @@ void __rseq_trace_ip_fixup(unsigned long ip, unsigned long start_ip,
123123}
124124#endif /* CONFIG_TRACEPOINTS */
125125
126- #ifdef CONFIG_DEBUG_FS
127126#ifdef CONFIG_RSEQ_STATS
128127DEFINE_PER_CPU (struct rseq_stats , rseq_stats );
129128
@@ -222,16 +221,19 @@ static const struct file_operations debug_ops = {
222221 .release = single_release ,
223222};
224223
224+ static void rseq_slice_ext_init (struct dentry * root_dir );
225+
225226static int __init rseq_debugfs_init (void )
226227{
227228 struct dentry * root_dir = debugfs_create_dir ("rseq" , NULL );
228229
229230 debugfs_create_file ("debug" , 0644 , root_dir , NULL , & debug_ops );
230231 rseq_stats_init (root_dir );
232+ if (IS_ENABLED (CONFIG_RSEQ_SLICE_EXTENSION ))
233+ rseq_slice_ext_init (root_dir );
231234 return 0 ;
232235}
233236__initcall (rseq_debugfs_init );
234- #endif /* CONFIG_DEBUG_FS */
235237
236238static bool rseq_set_ids (struct task_struct * t , struct rseq_ids * ids , u32 node_id )
237239{
@@ -515,7 +517,9 @@ struct slice_timer {
515517 void * cookie ;
516518};
517519
518- unsigned int rseq_slice_ext_nsecs __read_mostly = 10 * NSEC_PER_USEC ;
520+ static const unsigned int rseq_slice_ext_nsecs_min = 10 * NSEC_PER_USEC ;
521+ static const unsigned int rseq_slice_ext_nsecs_max = 50 * NSEC_PER_USEC ;
522+ unsigned int rseq_slice_ext_nsecs __read_mostly = rseq_slice_ext_nsecs_min ;
519523static DEFINE_PER_CPU (struct slice_timer , slice_timer );
520524DEFINE_STATIC_KEY_TRUE (rseq_slice_extension_key );
521525
@@ -761,30 +765,48 @@ SYSCALL_DEFINE0(rseq_slice_yield)
761765 return yielded ;
762766}
763767
764- #ifdef CONFIG_SYSCTL
765- static const unsigned int rseq_slice_ext_nsecs_min = 10 * NSEC_PER_USEC ;
766- static const unsigned int rseq_slice_ext_nsecs_max = 50 * NSEC_PER_USEC ;
768+ static int rseq_slice_ext_show (struct seq_file * m , void * p )
769+ {
770+ seq_printf (m , "%d\n" , rseq_slice_ext_nsecs );
771+ return 0 ;
772+ }
773+
774+ static ssize_t rseq_slice_ext_write (struct file * file , const char __user * ubuf ,
775+ size_t count , loff_t * ppos )
776+ {
777+ unsigned int nsecs ;
778+
779+ if (kstrtouint_from_user (ubuf , count , 10 , & nsecs ))
780+ return - EINVAL ;
781+
782+ if (nsecs < rseq_slice_ext_nsecs_min )
783+ return - ERANGE ;
767784
768- static const struct ctl_table rseq_slice_ext_sysctl [] = {
769- {
770- .procname = "rseq_slice_extension_nsec" ,
771- .data = & rseq_slice_ext_nsecs ,
772- .maxlen = sizeof (unsigned int ),
773- .mode = 0644 ,
774- .proc_handler = proc_douintvec_minmax ,
775- .extra1 = (unsigned int * )& rseq_slice_ext_nsecs_min ,
776- .extra2 = (unsigned int * )& rseq_slice_ext_nsecs_max ,
777- },
785+ if (nsecs > rseq_slice_ext_nsecs_max )
786+ return - ERANGE ;
787+
788+ rseq_slice_ext_nsecs = nsecs ;
789+
790+ return count ;
791+ }
792+
793+ static int rseq_slice_ext_open (struct inode * inode , struct file * file )
794+ {
795+ return single_open (file , rseq_slice_ext_show , inode -> i_private );
796+ }
797+
798+ static const struct file_operations slice_ext_ops = {
799+ .open = rseq_slice_ext_open ,
800+ .read = seq_read ,
801+ .write = rseq_slice_ext_write ,
802+ .llseek = seq_lseek ,
803+ .release = single_release ,
778804};
779805
780- static void rseq_slice_sysctl_init ( void )
806+ static void rseq_slice_ext_init ( struct dentry * root_dir )
781807{
782- if (rseq_slice_extension_enabled ())
783- register_sysctl_init ("kernel" , rseq_slice_ext_sysctl );
808+ debugfs_create_file ("slice_ext_nsec" , 0644 , root_dir , NULL , & slice_ext_ops );
784809}
785- #else /* CONFIG_SYSCTL */
786- static inline void rseq_slice_sysctl_init (void ) { }
787- #endif /* !CONFIG_SYSCTL */
788810
789811static int __init rseq_slice_cmdline (char * str )
790812{
@@ -807,8 +829,9 @@ static int __init rseq_slice_init(void)
807829 hrtimer_setup (per_cpu_ptr (& slice_timer .timer , cpu ), rseq_slice_expired ,
808830 CLOCK_MONOTONIC , HRTIMER_MODE_REL_PINNED_HARD );
809831 }
810- rseq_slice_sysctl_init ();
811832 return 0 ;
812833}
813834device_initcall (rseq_slice_init );
835+ #else
836+ static void rseq_slice_ext_init (struct dentry * root_dir ) { }
814837#endif /* CONFIG_RSEQ_SLICE_EXTENSION */
0 commit comments