Skip to contentSkip to conversation

kernel/time: move timer sysctls to its own file

PATCH Superseded tangmeng 4 participants 8 messages Jan 28, 2022 – Feb 16, 2022

Subsystems (3)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

tangmeng

author
#0 lore raw

PATCH v2 1/1 kernel/time: move timer sysctls to its own file

This moves the kernel/timer/timer.c respective sysctls to its own file.

---
 include/linux/timer.h |  4 ----
 kernel/sysctl.c       | 11 -----------
 kernel/time/timer.c   | 27 +++++++++++++++++++++++++--
 3 files changed, 25 insertions(+), 17 deletions(-)
include/linux/timer.h +0 -4
index fda13c9d1256..793b6b7c5a3e 100644
@@ -198,10 +198,6 @@ extern enum hrtimer_restart it_real_fn(struct hrtimer *);
 
 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
 struct ctl_table;
-
-extern unsigned int sysctl_timer_migration;
-int timer_migration_handler(struct ctl_table *table, int write,
-			    void *buffer, size_t *lenp, loff_t *ppos);
 #endif
 
 unsigned long __round_jiffies(unsigned long j, int cpu);
kernel/sysctl.c +0 -11
index 5ae443b2882e..d6d133423e5d 100644
@@ -2292,17 +2292,6 @@ static struct ctl_table kern_table[] = {
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_ONE,
 	},
-#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
-	{
-		.procname	= "timer_migration",
-		.data		= &sysctl_timer_migration,
-		.maxlen		= sizeof(unsigned int),
-		.mode		= 0644,
-		.proc_handler	= timer_migration_handler,
-		.extra1		= SYSCTL_ZERO,
-		.extra2		= SYSCTL_ONE,
-	},
-#endif
 #ifdef CONFIG_BPF_SYSCALL
 	{
 		.procname	= "unprivileged_bpf_disabled",
kernel/time/timer.c +25 -2
index 85f1021ad459..ee462673f638 100644
@@ -223,7 +223,7 @@ static void timer_update_keys(struct work_struct *work);
 static DECLARE_WORK(timer_update_work, timer_update_keys);
 
 #ifdef CONFIG_SMP
-unsigned int sysctl_timer_migration = 1;
+static unsigned int sysctl_timer_migration = 1;
 
 DEFINE_STATIC_KEY_FALSE(timers_migration_enabled);
 
@@ -251,7 +251,8 @@ void timers_update_nohz(void)
 	schedule_work(&timer_update_work);
 }
 
-int timer_migration_handler(struct ctl_table *table, int write,
+#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
+static int timer_migration_handler(struct ctl_table *table, int write,
 			    void *buffer, size_t *lenp, loff_t *ppos)
 {
 	int ret;
@@ -264,6 +265,27 @@ int timer_migration_handler(struct ctl_table *table, int write,
 	return ret;
 }
 
+static struct ctl_table timer_sysctl[] = {
+	{
+		.procname       = "timer_migration",
+		.data           = &sysctl_timer_migration,
+		.maxlen         = sizeof(unsigned int),
+		.mode           = 0644,
+		.proc_handler   = timer_migration_handler,
+		.extra1         = SYSCTL_ZERO,
+		.extra2         = SYSCTL_ONE,
+	},
+	{}
+};
+
+static int __init timer_sysctl_init(void)
+{
+	register_sysctl_init("kerneli/timer", timer_sysctl);
+	return 0;
+}
+#else
+#define timer_sysctl_init() do { } while (0)
+#endif
 static inline bool is_timers_nohz_active(void)
 {
 	return static_branch_unlikely(&timers_nohz_active);
@@ -2022,6 +2044,7 @@ void __init init_timers(void)
 	init_timer_cpus();
 	posix_cputimers_init_work();
 	open_softirq(TIMER_SOFTIRQ, run_timer_softirq);
+	timer_sysctl_init();
 }
 
 /**
Signature · 1 line
2.20.1
#1 lore raw
Thank you for the patch! Yet something to improve:

Hi tangmeng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/timers/core]
[also build test ERROR on linus/master kees/for-next/pstore v5.17-rc1 next-20220128] [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/tangmeng/kernel-time-move-timer-sysctls-to-its-own-file/20220128-165225
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 35e13e9da9afbce13c1d36465504ece4e65f24fe
config: arm64-randconfig-r026-20220127 (https://download.01.org/0day-ci/archive/20220129/202201290325.Jyor2i8O-lkp(a)intel.com/config)
compiler: aarch64-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/8bd44d33085f8ab50523016cbdb0c918dc4b4f3c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review tangmeng/kernel-time-move-timer-sysctls-to-its-own-file/20220128-165225 git checkout 8bd44d33085f8ab50523016cbdb0c918dc4b4f3c
# 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=arm64 SHELL=/bin/bash kernel/time/

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

kernel/time/timer.c: In function 'timer_sysctl_init':

>> kernel/time/timer.c:283:9: error: implicit declaration of function 'register_sysctl_init'; did you mean 'timer_sysctl_init'? [-Werror=implicit-function-declaration]
     283 |         register_sysctl_init("kerneli/timer", timer_sysctl);
         |         ^~~~~~~~~~~~~~~~~~~~
         |         timer_sysctl_init

cc1: some warnings being treated as errors

vim +283 kernel/time/timer.c

280
281 static int __init timer_sysctl_init(void)
282 {

 > 283		register_sysctl_init("kerneli/timer", timer_sysctl);

284 return 0;
285 }
286 #else
287 #define timer_sysctl_init() do { } while (0)
288 #endif
289 static inline bool is_timers_nohz_active(void)
290 {
291 return static_branch_unlikely(&timers_nohz_active);
292 }
293 #else
294 static inline bool is_timers_nohz_active(void) { return false; }
295 #endif /* NO_HZ_COMMON */
296

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw

These complaints are using and assuming and older kernel.

Luis

Quoted 61 lines · kernel test robot

Hi tangmeng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/timers/core]
[also build test ERROR on linus/master kees/for-next/pstore v5.17-rc1 next-20220128] [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/tangmeng/kernel-time-move-timer-sysctls-to-its-own-file/20220128-165225
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 35e13e9da9afbce13c1d36465504ece4e65f24fe
config: arm64-randconfig-r026-20220127 (https://download.01.org/0day-ci/archive/20220129/202201290325.Jyor2i8O-lkp(a)intel.com/config)
compiler: aarch64-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/8bd44d33085f8ab50523016cbdb0c918dc4b4f3c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review tangmeng/kernel-time-move-timer-sysctls-to-its-own-file/20220128-165225 git checkout 8bd44d33085f8ab50523016cbdb0c918dc4b4f3c
# 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=arm64 SHELL=/bin/bash kernel/time/

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

kernel/time/timer.c: In function 'timer_sysctl_init':

Quoted 1 line
Quoted 1 line

kernel/time/timer.c:283:9: error: implicit declaration of function 'register_sysctl_init'; did you mean 'timer_sysctl_init'? [-Werror=implicit-function-declaration]

     283 |         register_sysctl_init("kerneli/timer", timer_sysctl);
         |         ^~~~~~~~~~~~~~~~~~~~
         |         timer_sysctl_init

cc1: some warnings being treated as errors

vim +283 kernel/time/timer.c

   280	
   281	static int __init timer_sysctl_init(void)
   282	{
Quoted 1 line

283 register_sysctl_init("kerneli/timer", timer_sysctl);

   284		return 0;
   285	}
   286	#else
   287	#define timer_sysctl_init() do { } while (0)
   288	#endif
   289	static inline bool is_timers_nohz_active(void)
   290	{
   291		return static_branch_unlikely(&timers_nohz_active);
   292	}
   293	#else
   294	static inline bool is_timers_nohz_active(void) { return false; }
   295	#endif /* NO_HZ_COMMON */
   296	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

author
#3 lore raw

Maybe this is related to the kernel/time directory specified in the compilation instruction.

> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm64 SHELL=/bin/bash kernel/time/

register_sysctl_init is implemented in the kernel tree. If it is only in the specified kernel/time tree, it may not be linked to register_sysctl_init implementation.

But I don't know how to take the best way to avoid this problem.

发自我的企业微信

 

----------Reply to Message----------
On Wed, Feb 2, 2022 10:40 AM Luis Chamberlain<mcgrof(a)kernel.org&gt; wrote:

These complaints are using and assuming and older kernel.

&nbsp;Luis

On Sat, Jan 29, 2022@05:03:38AM +0800, kernel test robot wrote:
&gt; Hi tangmeng,
&gt;
&gt; Thank you for the patch! Yet something to improve:
&gt;
&gt; [auto build test ERROR on tip/timers/core]
&gt; [also build test ERROR on linus/master kees/for-next/pstore v5.17-rc1 next-20220128]
&gt; [If your patch is applied to the wrong git tree, kindly drop us a note.
&gt; And when submitting patch, we suggest to use '--base' as documented in
&gt; https://git-scm.com/docs/git-format-patch]
&gt;
&gt; url:&nbsp;&nbsp;&nbsp; https://github.com/0day-ci/linux/commits/tangmeng/kernel-time-move-timer-sysctls-to-its-own-file/20220128-165225
&gt; base:&nbsp;&nbsp; https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 35e13e9da9afbce13c1d36465504ece4e65f24fe
&gt; config: arm64-randconfig-r026-20220127 (https://download.01.org/0day-ci/archive/20220129/202201290325.Jyor2i8O-lkp(a)intel.com/config)
&gt; compiler: aarch64-linux-gcc (GCC) 11.2.0
&gt; reproduce (this is a W=1 build):
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chmod +x ~/bin/make.cross
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # https://github.com/0day-ci/linux/commit/8bd44d33085f8ab50523016cbdb0c918dc4b4f3c
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; git remote add linux-review https://github.com/0day-ci/linux
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; git fetch --no-tags linux-review tangmeng/kernel-time-move-timer-sysctls-to-its-own-file/20220128-165225 &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; git checkout 8bd44d33085f8ab50523016cbdb0c918dc4b4f3c &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # save the config file to linux build tree
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mkdir build_dir
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm64 SHELL=/bin/bash kernel/time/ &gt;
&gt; If you fix the issue, kindly add following tag as appropriate
&gt; Reported-by: kernel test robot <lkp(a)intel.com&gt;
&gt;
&gt; All errors (new ones prefixed by &gt;&gt;):
&gt;
&gt;&nbsp;&nbsp;&nbsp; kernel/time/timer.c: In function 'timer_sysctl_init':
&gt; &gt;&gt; kernel/time/timer.c:283:9: error: implicit declaration of function 'register_sysctl_init'; did you mean 'timer_sysctl_init'? [-Werror=implicit-function-declaration] &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 283 |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; register_sysctl_init("kerneli/timer", timer_sysctl); &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^~~~~~~~~~~~~~~~~~~~ &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timer_sysctl_init
&gt;&nbsp;&nbsp;&nbsp; cc1: some warnings being treated as errors
&gt;
&gt;
&gt; vim +283 kernel/time/timer.c
&gt;
&gt;&nbsp;&nbsp;&nbsp; 280
&gt;&nbsp;&nbsp;&nbsp; 281static int __init timer_sysctl_init(void)
&gt;&nbsp;&nbsp;&nbsp; 282{
&gt;&nbsp; &gt; 283register_sysctl_init("kerneli/timer", timer_sysctl);
&gt;&nbsp;&nbsp;&nbsp; 284return 0;
&gt;&nbsp;&nbsp;&nbsp; 285}
&gt;&nbsp;&nbsp;&nbsp; 286#else
&gt;&nbsp;&nbsp;&nbsp; 287#define timer_sysctl_init() do { } while (0)
&gt;&nbsp;&nbsp;&nbsp; 288#endif
&gt;&nbsp;&nbsp;&nbsp; 289static inline bool is_timers_nohz_active(void)
&gt;&nbsp;&nbsp;&nbsp; 290{
&gt;&nbsp;&nbsp;&nbsp; 291return static_branch_unlikely(&amp;timers_nohz_active);
&gt;&nbsp;&nbsp;&nbsp; 292}
&gt;&nbsp;&nbsp;&nbsp; 293#else
&gt;&nbsp;&nbsp;&nbsp; 294static inline bool is_timers_nohz_active(void) { return false; }
&gt;&nbsp;&nbsp;&nbsp; 295#endif /* NO_HZ_COMMON */
&gt;&nbsp;&nbsp;&nbsp; 296
&gt;
&gt; ---
&gt; 0-DAY CI Kernel Test Service, Intel Corporation
&gt; https://lists.01.org/hyperkitty/list/[email protected]

#4 lore raw
In reply to Luis Chamberlain

Hi Luis,

Thanks for the feedback, we'll take a look.

Best Regards,
Rong Chen

Quoted 70 lines · Luis Chamberlain

These complaints are using and assuming and older kernel.

Luis

Quoted 58 lines · kernel test robot

Hi tangmeng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/timers/core]
[also build test ERROR on linus/master kees/for-next/pstore v5.17-rc1 next-20220128] [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/tangmeng/kernel-time-move-timer-sysctls-to-its-own-file/20220128-165225
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 35e13e9da9afbce13c1d36465504ece4e65f24fe
config: arm64-randconfig-r026-20220127 (https://download.01.org/0day-ci/archive/20220129/202201290325.Jyor2i8O-lkp(a)intel.com/config)
compiler: aarch64-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/8bd44d33085f8ab50523016cbdb0c918dc4b4f3c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review tangmeng/kernel-time-move-timer-sysctls-to-its-own-file/20220128-165225 git checkout 8bd44d33085f8ab50523016cbdb0c918dc4b4f3c
# 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=arm64 SHELL=/bin/bash kernel/time/

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

kernel/time/timer.c: In function 'timer_sysctl_init':

Quoted 1 line
Quoted 1 line

kernel/time/timer.c:283:9: error: implicit declaration of function 'register_sysctl_init'; did you mean 'timer_sysctl_init'? [-Werror=implicit-function-declaration]

      283 |         register_sysctl_init("kerneli/timer", timer_sysctl);
          |         ^~~~~~~~~~~~~~~~~~~~
          |         timer_sysctl_init

cc1: some warnings being treated as errors

vim +283 kernel/time/timer.c

    280	
    281	static int __init timer_sysctl_init(void)
    282	{
Quoted 1 line

283 register_sysctl_init("kerneli/timer", timer_sysctl);

    284		return 0;
    285	}
    286	#else
    287	#define timer_sysctl_init() do { } while (0)
    288	#endif
    289	static inline bool is_timers_nohz_active(void)
    290	{
    291		return static_branch_unlikely(&timers_nohz_active);
    292	}
    293	#else
    294	static inline bool is_timers_nohz_active(void) { return false; }
    295	#endif /* NO_HZ_COMMON */
    296	
Quoted 3 lines

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

_______________________________________________
kbuild-all mailing list -- kbuild-all(a)lists.01.org To unsubscribe send an email to kbuild-all-leave(a)lists.01.org

#5 lore raw
Quoted 3 lines · Rong A

Hi Luis,

Thanks for the feedback, we'll take a look.

Sorry for the noise but it could also have been an ifdef is needed when proc sysctl is disabled. In either case tangmeng said he'd look into it.

Luis

author
#6 lore raw
Quoted 10 lines · Luis Chamberlain
Quoted 3 lines · Rong A

Hi Luis,

Thanks for the feedback, we'll take a look.

Sorry for the noise but it could also have been an ifdef is needed when proc sysctl is disabled. In either case tangmeng said he'd look into it.

Luis

Thanks for the heads up! I will handle it.
Best regards

author
#7 lore raw
In reply to Luis Chamberlain
Quoted 10 lines · Luis Chamberlain
Quoted 3 lines · Rong A

Hi Luis,

Thanks for the feedback, we'll take a look.

Sorry for the noise but it could also have been an ifdef is needed when proc sysctl is disabled. In either case tangmeng said he'd look into it.

Luis

Thanks for the heads up! I have handled it in patch v7. Best regards