diff mbox series

[3/8] sched: Move rt_period/runtime sysctls to rt.c

Message ID 20220215052214.5286-4-nizhen@uniontech.com (mailing list archive)
State New, archived
Headers show
Series sched: Move a series of sysctls starting with sys/kernel/sched_* | expand

Commit Message

Zhen Ni Feb. 15, 2022, 5:22 a.m. UTC
move rt_period/runtime sysctls to rt.c and use the new
register_sysctl_init() to register the sysctl interface.

Signed-off-by: Zhen Ni <nizhen@uniontech.com>
---
 include/linux/sched/sysctl.h | 11 ---------
 kernel/sched/core.c          | 13 -----------
 kernel/sched/rt.c            | 43 +++++++++++++++++++++++++++++++++++-
 kernel/sched/sched.h         |  4 ++++
 kernel/sysctl.c              | 14 ------------
 5 files changed, 46 insertions(+), 39 deletions(-)

Comments

kernel test robot Feb. 15, 2022, 7:47 a.m. UTC | #1
Hi Zhen,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/sched/core]
[also build test ERROR on linus/master kees/for-next/pstore v5.17-rc4]
[cannot apply to next-20220214]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Zhen-Ni/sched-Move-a-series-of-sysctls-starting-with-sys-kernel-sched_/20220215-132416
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 3624ba7b5e2acc02b01301ea5fd3534971eb9896
config: parisc-randconfig-r023-20220214 (https://download.01.org/0day-ci/archive/20220215/202202151509.TszSxsaB-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/f93266963b3b3629980fa3384a5e37fd13f4c350
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Zhen-Ni/sched-Move-a-series-of-sysctls-starting-with-sys-kernel-sched_/20220215-132416
        git checkout f93266963b3b3629980fa3384a5e37fd13f4c350
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=parisc SHELL=/bin/bash kernel/rcu/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   kernel/rcu/rcutorture.c: In function 'rcu_torture_disable_rt_throttle':
>> kernel/rcu/rcutorture.c:921:26: error: 'sysctl_sched_rt_runtime' undeclared (first use in this function); did you mean 'sysctl_sched_rr_timeslice'?
     921 |         old_rt_runtime = sysctl_sched_rt_runtime;
         |                          ^~~~~~~~~~~~~~~~~~~~~~~
         |                          sysctl_sched_rr_timeslice
   kernel/rcu/rcutorture.c:921:26: note: each undeclared identifier is reported only once for each function it appears in
   kernel/rcu/rcutorture.c: In function 'rcu_torture_enable_rt_throttle':
   kernel/rcu/rcutorture.c:930:9: error: 'sysctl_sched_rt_runtime' undeclared (first use in this function); did you mean 'sysctl_sched_rr_timeslice'?
     930 |         sysctl_sched_rt_runtime = old_rt_runtime;
         |         ^~~~~~~~~~~~~~~~~~~~~~~
         |         sysctl_sched_rr_timeslice


vim +921 kernel/rcu/rcutorture.c

450efca7182a51 Joel Fernandes (Google  2018-06-10  909) 
450efca7182a51 Joel Fernandes (Google  2018-06-10  910) static void rcu_torture_disable_rt_throttle(void)
450efca7182a51 Joel Fernandes (Google  2018-06-10  911) {
450efca7182a51 Joel Fernandes (Google  2018-06-10  912) 	/*
450efca7182a51 Joel Fernandes (Google  2018-06-10  913) 	 * Disable RT throttling so that rcutorture's boost threads don't get
450efca7182a51 Joel Fernandes (Google  2018-06-10  914) 	 * throttled. Only possible if rcutorture is built-in otherwise the
450efca7182a51 Joel Fernandes (Google  2018-06-10  915) 	 * user should manually do this by setting the sched_rt_period_us and
450efca7182a51 Joel Fernandes (Google  2018-06-10  916) 	 * sched_rt_runtime sysctls.
450efca7182a51 Joel Fernandes (Google  2018-06-10  917) 	 */
450efca7182a51 Joel Fernandes (Google  2018-06-10  918) 	if (!IS_BUILTIN(CONFIG_RCU_TORTURE_TEST) || old_rt_runtime != -1)
450efca7182a51 Joel Fernandes (Google  2018-06-10  919) 		return;
450efca7182a51 Joel Fernandes (Google  2018-06-10  920) 
450efca7182a51 Joel Fernandes (Google  2018-06-10 @921) 	old_rt_runtime = sysctl_sched_rt_runtime;
450efca7182a51 Joel Fernandes (Google  2018-06-10  922) 	sysctl_sched_rt_runtime = -1;
450efca7182a51 Joel Fernandes (Google  2018-06-10  923) }
450efca7182a51 Joel Fernandes (Google  2018-06-10  924) 

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Luis Chamberlain Feb. 15, 2022, 7:53 a.m. UTC | #2
Zhen,

please get lkp to add your git tree to test it before you submit
patches. The FAQ for Intel lkp describes what to do.

 Luis
kernel test robot Feb. 15, 2022, 11:23 a.m. UTC | #3
Hi Zhen,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/sched/core]
[also build test ERROR on linus/master kees/for-next/pstore v5.17-rc4]
[cannot apply to next-20220214]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Zhen-Ni/sched-Move-a-series-of-sysctls-starting-with-sys-kernel-sched_/20220215-132416
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 3624ba7b5e2acc02b01301ea5fd3534971eb9896
config: hexagon-randconfig-r033-20220214 (https://download.01.org/0day-ci/archive/20220215/202202151705.Uez40mBM-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 37f422f4ac31c8b8041c6b62065263314282dab6)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/f93266963b3b3629980fa3384a5e37fd13f4c350
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Zhen-Ni/sched-Move-a-series-of-sysctls-starting-with-sys-kernel-sched_/20220215-132416
        git checkout f93266963b3b3629980fa3384a5e37fd13f4c350
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash kernel/rcu/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   kernel/rcu/rcutorture.c:380:16: warning: variable 'started' set but not used [-Wunused-but-set-variable]
           unsigned long started;
                         ^
   kernel/rcu/rcutorture.c:381:16: warning: variable 'completed' set but not used [-Wunused-but-set-variable]
           unsigned long completed;
                         ^
   kernel/rcu/rcutorture.c:384:21: warning: variable 'ts' set but not used [-Wunused-but-set-variable]
           unsigned long long ts;
                              ^
>> kernel/rcu/rcutorture.c:921:19: error: use of undeclared identifier 'sysctl_sched_rt_runtime'; did you mean 'sysctl_sched_rr_timeslice'?
           old_rt_runtime = sysctl_sched_rt_runtime;
                            ^~~~~~~~~~~~~~~~~~~~~~~
                            sysctl_sched_rr_timeslice
   include/linux/sched/sysctl.h:37:12: note: 'sysctl_sched_rr_timeslice' declared here
   extern int sysctl_sched_rr_timeslice;
              ^
   kernel/rcu/rcutorture.c:922:2: error: use of undeclared identifier 'sysctl_sched_rt_runtime'
           sysctl_sched_rt_runtime = -1;
           ^
   kernel/rcu/rcutorture.c:930:2: error: use of undeclared identifier 'sysctl_sched_rt_runtime'
           sysctl_sched_rt_runtime = old_rt_runtime;
           ^
   kernel/rcu/rcutorture.c:1620:21: warning: variable 'ts' set but not used [-Wunused-but-set-variable]
           unsigned long long ts;
                              ^
   4 warnings and 3 errors generated.


vim +921 kernel/rcu/rcutorture.c

450efca7182a516 Joel Fernandes (Google  2018-06-10  909) 
450efca7182a516 Joel Fernandes (Google  2018-06-10  910) static void rcu_torture_disable_rt_throttle(void)
450efca7182a516 Joel Fernandes (Google  2018-06-10  911) {
450efca7182a516 Joel Fernandes (Google  2018-06-10  912) 	/*
450efca7182a516 Joel Fernandes (Google  2018-06-10  913) 	 * Disable RT throttling so that rcutorture's boost threads don't get
450efca7182a516 Joel Fernandes (Google  2018-06-10  914) 	 * throttled. Only possible if rcutorture is built-in otherwise the
450efca7182a516 Joel Fernandes (Google  2018-06-10  915) 	 * user should manually do this by setting the sched_rt_period_us and
450efca7182a516 Joel Fernandes (Google  2018-06-10  916) 	 * sched_rt_runtime sysctls.
450efca7182a516 Joel Fernandes (Google  2018-06-10  917) 	 */
450efca7182a516 Joel Fernandes (Google  2018-06-10  918) 	if (!IS_BUILTIN(CONFIG_RCU_TORTURE_TEST) || old_rt_runtime != -1)
450efca7182a516 Joel Fernandes (Google  2018-06-10  919) 		return;
450efca7182a516 Joel Fernandes (Google  2018-06-10  920) 
450efca7182a516 Joel Fernandes (Google  2018-06-10 @921) 	old_rt_runtime = sysctl_sched_rt_runtime;
450efca7182a516 Joel Fernandes (Google  2018-06-10  922) 	sysctl_sched_rt_runtime = -1;
450efca7182a516 Joel Fernandes (Google  2018-06-10  923) }
450efca7182a516 Joel Fernandes (Google  2018-06-10  924) 

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
index ffe42509a595..99fbf61464ab 100644
--- a/include/linux/sched/sysctl.h
+++ b/include/linux/sched/sysctl.h
@@ -21,15 +21,6 @@  enum sched_tunable_scaling {
 	SCHED_TUNABLESCALING_END,
 };
 
-/*
- *  control realtime throttling:
- *
- *  /proc/sys/kernel/sched_rt_period_us
- *  /proc/sys/kernel/sched_rt_runtime_us
- */
-extern unsigned int sysctl_sched_rt_period;
-extern int sysctl_sched_rt_runtime;
-
 extern unsigned int sysctl_sched_dl_period_max;
 extern unsigned int sysctl_sched_dl_period_min;
 
@@ -48,8 +39,6 @@  extern int sched_rr_timeslice;
 
 int sched_rr_handler(struct ctl_table *table, int write, void *buffer,
 		size_t *lenp, loff_t *ppos);
-int sched_rt_handler(struct ctl_table *table, int write, void *buffer,
-		size_t *lenp, loff_t *ppos);
 int sysctl_sched_uclamp_handler(struct ctl_table *table, int write,
 		void *buffer, size_t *lenp, loff_t *ppos);
 int sysctl_numa_balancing(struct ctl_table *table, int write, void *buffer,
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3c1239c61b45..276033cceaf2 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -81,12 +81,6 @@  const_debug unsigned int sysctl_sched_nr_migrate = 8;
 const_debug unsigned int sysctl_sched_nr_migrate = 32;
 #endif
 
-/*
- * period over which we measure -rt task CPU usage in us.
- * default: 1s
- */
-unsigned int sysctl_sched_rt_period = 1000000;
-
 __read_mostly int scheduler_running;
 
 #ifdef CONFIG_SCHED_CORE
@@ -380,13 +374,6 @@  sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags) { }
 
 #endif /* CONFIG_SCHED_CORE */
 
-/*
- * part of the period that we allow rt tasks to run in us.
- * default: 0.95s
- */
-int sysctl_sched_rt_runtime = 950000;
-
-
 /*
  * Serialization rules:
  *
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 7b4f4fbbb404..1106828c4236 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -16,6 +16,47 @@  static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun);
 
 struct rt_bandwidth def_rt_bandwidth;
 
+/*
+ * period over which we measure -rt task CPU usage in us.
+ * default: 1s
+ */
+unsigned int sysctl_sched_rt_period = 1000000;
+
+/*
+ * part of the period that we allow rt tasks to run in us.
+ * default: 0.95s
+ */
+int sysctl_sched_rt_runtime = 950000;
+
+static int sched_rt_handler(struct ctl_table *table, int write, void *buffer,
+		size_t *lenp, loff_t *ppos);
+#ifdef CONFIG_SYSCTL
+static struct ctl_table sched_rt_sysctls[] = {
+	{
+		.procname       = "sched_rt_period_us",
+		.data           = &sysctl_sched_rt_period,
+		.maxlen         = sizeof(unsigned int),
+		.mode           = 0644,
+		.proc_handler   = sched_rt_handler,
+	},
+	{
+		.procname       = "sched_rt_runtime_us",
+		.data           = &sysctl_sched_rt_runtime,
+		.maxlen         = sizeof(int),
+		.mode           = 0644,
+		.proc_handler   = sched_rt_handler,
+	},
+	{}
+};
+
+static int __init sched_rt_sysctl_init(void)
+{
+	register_sysctl_init("kernel", sched_rt_sysctls);
+	return 0;
+}
+late_initcall(sched_rt_sysctl_init);
+#endif
+
 static enum hrtimer_restart sched_rt_period_timer(struct hrtimer *timer)
 {
 	struct rt_bandwidth *rt_b =
@@ -2928,7 +2969,7 @@  static void sched_rt_do_global(void)
 	raw_spin_unlock_irqrestore(&def_rt_bandwidth.rt_runtime_lock, flags);
 }
 
-int sched_rt_handler(struct ctl_table *table, int write, void *buffer,
+static int sched_rt_handler(struct ctl_table *table, int write, void *buffer,
 		size_t *lenp, loff_t *ppos)
 {
 	int old_period, old_runtime;
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 27465635c774..385e74095434 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -102,6 +102,10 @@  extern void calc_global_load_tick(struct rq *this_rq);
 extern long calc_load_fold_active(struct rq *this_rq, long adjust);
 
 extern void call_trace_sched_update_nr_running(struct rq *rq, int count);
+
+extern unsigned int sysctl_sched_rt_period;
+extern int sysctl_sched_rt_runtime;
+
 /*
  * Helpers for converting nanosecond timing to jiffy resolution
  */
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 88ff6b27f8ab..73cccd935d65 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1674,20 +1674,6 @@  static struct ctl_table kern_table[] = {
 		.extra2		= SYSCTL_ONE,
 	},
 #endif /* CONFIG_NUMA_BALANCING */
-	{
-		.procname	= "sched_rt_period_us",
-		.data		= &sysctl_sched_rt_period,
-		.maxlen		= sizeof(unsigned int),
-		.mode		= 0644,
-		.proc_handler	= sched_rt_handler,
-	},
-	{
-		.procname	= "sched_rt_runtime_us",
-		.data		= &sysctl_sched_rt_runtime,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= sched_rt_handler,
-	},
 	{
 		.procname	= "sched_deadline_period_max_us",
 		.data		= &sysctl_sched_dl_period_max,