Skip to contentSkip to conversation

kernel/watchdog.c:74:22: warning: unused variable 'hardlockup_si_mask'

PATCH kernel test robot 4 participants 6 messages Dec 3, 2025 – Dec 4, 2025 Memory management

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   47b7b5e32bb7264b51b89186043e1ada4090b558
commit: a9af76a78760717361cccc884dc649e30db61c8b [9966/13055] watchdog: add sys_info sysctls to dump sys info on system lockup
config: powerpc64-randconfig-002-20251203 (https://download.01.org/0day-ci/archive/20251203/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 734a912d0f025559fcf76bde9aaaeb0383c1625a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251203/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> kernel/watchdog.c:74:22: warning: unused variable 'hardlockup_si_mask' [-Wunused-variable]
      74 | static unsigned long hardlockup_si_mask;
         |                      ^~~~~~~~~~~~~~~~~~

1 warning generated.

vim +/hardlockup_si_mask +74 kernel/watchdog.c

    62	
    63	/*
    64	 * Should we panic when a soft-lockup or hard-lockup occurs:
    65	 */
    66	unsigned int __read_mostly hardlockup_panic =
    67				IS_ENABLED(CONFIG_BOOTPARAM_HARDLOCKUP_PANIC);
    68	
    69	/*
    70	 * bitmasks to control what kinds of system info to be printed when
    71	 * hard lockup is detected, it could be task, memory, lock etc.
    72	 * Refer include/linux/sys_info.h for detailed bit definition.
    73	 */
  > 74	static unsigned long hardlockup_si_mask;
    75	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw

Hi,

Thanks for the reporting!

Quoted 12 lines · kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   47b7b5e32bb7264b51b89186043e1ada4090b558
commit: a9af76a78760717361cccc884dc649e30db61c8b [9966/13055] watchdog: add sys_info sysctls to dump sys info on system lockup
config: powerpc64-randconfig-002-20251203 (https://download.01.org/0day-ci/archive/20251203/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 734a912d0f025559fcf76bde9aaaeb0383c1625a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251203/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

Quoted 6 lines

All warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

kernel/watchdog.c:74:22: warning: unused variable 'hardlockup_si_mask' [-Wunused-variable]

      74 | static unsigned long hardlockup_si_mask;
         |                      ^~~~~~~~~~~~~~~~~~

1 warning generated.

I can't reproduce it right now as I'm on travel and only have ARM server to use. (The reproducer need a powerpc64 machine, or have a x86 machine to use your reproducer script).

Could you help to test the below patch? thank!

- Feng

---

kernel/watchdog.c +9 -7
index 1f59b950c475..5e5ac82a01f3 100644
@@ -66,13 +66,6 @@ int __read_mostly sysctl_hardlockup_all_cpu_backtrace;
 unsigned int __read_mostly hardlockup_panic =
 			IS_ENABLED(CONFIG_BOOTPARAM_HARDLOCKUP_PANIC);
 
-/*
- * bitmasks to control what kinds of system info to be printed when
- * hard lockup is detected, it could be task, memory, lock etc.
- * Refer include/linux/sys_info.h for detailed bit definition.
- */
-static unsigned long hardlockup_si_mask;
-
 #ifdef CONFIG_SYSFS
 
 static unsigned int hardlockup_count;
@@ -141,6 +134,13 @@ static DEFINE_PER_CPU(bool, watchdog_hardlockup_warned);
 static DEFINE_PER_CPU(bool, watchdog_hardlockup_touched);
 static unsigned long hard_lockup_nmi_warn;
 
+/*
+ * bitmasks to control what kinds of system info to be printed when
+ * hard lockup is detected, it could be task, memory, lock etc.
+ * Refer include/linux/sys_info.h for detailed bit definition.
+ */
+static unsigned long hardlockup_si_mask;
+
 notrace void arch_touch_nmi_watchdog(void)
 {
 	/*
@@ -1250,6 +1250,7 @@ static const struct ctl_table watchdog_sysctls[] = {
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_ONE,
 	},
+#ifdef CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER
 	{
 		.procname	= "hardlockup_sys_info",
 		.data		= &hardlockup_si_mask,
@@ -1257,6 +1258,7 @@ static const struct ctl_table watchdog_sysctls[] = {
 		.mode		= 0644,
 		.proc_handler	= sysctl_sys_info_handler,
 	},
+#endif
 #ifdef CONFIG_SMP
 	{
 		.procname	= "hardlockup_all_cpu_backtrace",
maintainer
#2 lore raw
In reply to kernel test robot
Quoted 12 lines · On Wed, 3 Dec 2025 09:05:30 +0800 kernel test robot <[email protected]> wrote:
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   47b7b5e32bb7264b51b89186043e1ada4090b558
commit: a9af76a78760717361cccc884dc649e30db61c8b [9966/13055] watchdog: add sys_info sysctls to dump sys info on system lockup
config: powerpc64-randconfig-002-20251203 (https://download.01.org/0day-ci/archive/20251203/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 734a912d0f025559fcf76bde9aaaeb0383c1625a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251203/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

Quoted 6 lines

All warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

kernel/watchdog.c:74:22: warning: unused variable 'hardlockup_si_mask' [-Wunused-variable]

      74 | static unsigned long hardlockup_si_mask;
         |                      ^~~~~~~~~~~~~~~~~~

1 warning generated.

I'm testing the appended patch but it needs checking please.

The comment for hardlockup_si_mask says

* bitmask to control what kinds of system info to be printed when
* hard lockup is detected, it could be task, memory, lock etc.
* Refer include/linux/sys_info.h for detailed bit definition.

but the variable depends on "COUNTS_HRTIMER". The comment doesn't mention hrtimers and I don't see why it should. Not sure what's going on here.

From: Andrew Morton <[email protected]>
Subject: kernel/watchdog.c: fix unused var warning
Date: Wed Dec 3 02:34:40 PM PST 2025

Quoted 1 line
Quoted 1 line

kernel/watchdog.c:74:22: warning: unused variable 'hardlockup_si_mask' [-Wunused-variable]

      74 | static unsigned long hardlockup_si_mask;
         |                      ^~~~~~~~~~~~~~~~~~

1 warning generated.

Fixes a9af76a78760 ("watchdog: add sys_info sysctls to dump sys info on system lockup")
Cc Feng Tang <[email protected]>
Cc Petr Mladek <[email protected]>

---

 kernel/watchdog.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
kernel/watchdog.c renamed from kernel/watchdog.c~kernel-watchdogc-fix-unused-var-warning +9 -7
@@ -66,13 +66,6 @@ int __read_mostly sysctl_hardlockup_all_
 unsigned int __read_mostly hardlockup_panic =
 			IS_ENABLED(CONFIG_BOOTPARAM_HARDLOCKUP_PANIC);
 
-/*
- * bitmasks to control what kinds of system info to be printed when
- * hard lockup is detected, it could be task, memory, lock etc.
- * Refer include/linux/sys_info.h for detailed bit definition.
- */
-static unsigned long hardlockup_si_mask;
-
 #ifdef CONFIG_SYSFS
 
 static unsigned int hardlockup_count;
@@ -135,6 +128,13 @@ __setup("nmi_watchdog=", hardlockup_pani
 
 #if defined(CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER)
 
+/*
+ * bitmask to control what kinds of system info to be printed when
+ * hard lockup is detected, it could be task, memory, lock etc.
+ * Refer include/linux/sys_info.h for detailed bit definition.
+ */
+static unsigned long hardlockup_si_mask;
+
 static DEFINE_PER_CPU(atomic_t, hrtimer_interrupts);
 static DEFINE_PER_CPU(int, hrtimer_interrupts_saved);
 static DEFINE_PER_CPU(bool, watchdog_hardlockup_warned);
@@ -1250,6 +1250,7 @@ static const struct ctl_table watchdog_s
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_ONE,
 	},
+#if defined(CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER)
 	{
 		.procname	= "hardlockup_sys_info",
 		.data		= &hardlockup_si_mask,
@@ -1257,6 +1258,7 @@ static const struct ctl_table watchdog_s
 		.mode		= 0644,
 		.proc_handler	= sysctl_sys_info_handler,
 	},
+#endif
 #ifdef CONFIG_SMP
 	{
 		.procname	= "hardlockup_all_cpu_backtrace",

_

#3 lore raw
Quoted 25 lines · Andrew Morton
Quoted 12 lines · On Wed, 3 Dec 2025 09:05:30 +0800 kernel test robot <[email protected]> wrote:
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   47b7b5e32bb7264b51b89186043e1ada4090b558
commit: a9af76a78760717361cccc884dc649e30db61c8b [9966/13055] watchdog: add sys_info sysctls to dump sys info on system lockup
config: powerpc64-randconfig-002-20251203 (https://download.01.org/0day-ci/archive/20251203/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 734a912d0f025559fcf76bde9aaaeb0383c1625a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251203/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

Quoted 6 lines

All warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

kernel/watchdog.c:74:22: warning: unused variable 'hardlockup_si_mask' [-Wunused-variable]

      74 | static unsigned long hardlockup_si_mask;
         |                      ^~~~~~~~~~~~~~~~~~

1 warning generated.

I'm testing the appended patch but it needs checking please.

The comment for hardlockup_si_mask says

Quoted 7 lines

* bitmask to control what kinds of system info to be printed when
* hard lockup is detected, it could be task, memory, lock etc.
* Refer include/linux/sys_info.h for detailed bit definition.

but the variable depends on "COUNTS_HRTIMER". The comment doesn't mention hrtimers and I don't see why it should. Not sure what's going on here.

Good point! It took me some time to understand it.

So, powerpc implements its own watchog, see arch/powerpc/kernel/watchdog.c. The watchdog is supported only by some powerpc platforms, see the
following line in arch/powerpc/Kconfig:

	select HAVE_HARDLOCKUP_DETECTOR_ARCH	if PPC_BOOK3S_64 && SMP

As a result, the test system could have the following in the config,
see https://download.01.org/0day-ci/archive/20251203/[email protected]/config

CONFIG_HARDLOCKUP_DETECTOR=y
# CONFIG_HARDLOCKUP_DETECTOR_PERF is not set # CONFIG_HARDLOCKUP_DETECTOR_BUDDY is not set CONFIG_HARDLOCKUP_DETECTOR_ARCH=y

And "COUNTS_HRTIMER" is not defined.

Quoted 67 lines

From: Andrew Morton <[email protected]>
Subject: kernel/watchdog.c: fix unused var warning
Date: Wed Dec 3 02:34:40 PM PST 2025

Quoted 1 line
Quoted 1 line

kernel/watchdog.c:74:22: warning: unused variable 'hardlockup_si_mask' [-Wunused-variable]

      74 | static unsigned long hardlockup_si_mask;
         |                      ^~~~~~~~~~~~~~~~~~

1 warning generated.

Fixes a9af76a78760 ("watchdog: add sys_info sysctls to dump sys info on system lockup")
Cc Feng Tang <[email protected]>
Cc Petr Mladek <[email protected]>

---

 kernel/watchdog.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
kernel/watchdog.c renamed from kernel/watchdog.c~kernel-watchdogc-fix-unused-var-warning +9 -7
@@ -66,13 +66,6 @@ int __read_mostly sysctl_hardlockup_all_
 unsigned int __read_mostly hardlockup_panic =
 			IS_ENABLED(CONFIG_BOOTPARAM_HARDLOCKUP_PANIC);
 
-/*
- * bitmasks to control what kinds of system info to be printed when
- * hard lockup is detected, it could be task, memory, lock etc.
- * Refer include/linux/sys_info.h for detailed bit definition.
- */
-static unsigned long hardlockup_si_mask;
-
 #ifdef CONFIG_SYSFS
 
 static unsigned int hardlockup_count;
@@ -135,6 +128,13 @@ __setup("nmi_watchdog=", hardlockup_pani
 
 #if defined(CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER)
 
+/*
+ * bitmask to control what kinds of system info to be printed when
+ * hard lockup is detected, it could be task, memory, lock etc.
+ * Refer include/linux/sys_info.h for detailed bit definition.
+ */
+static unsigned long hardlockup_si_mask;
+
 static DEFINE_PER_CPU(atomic_t, hrtimer_interrupts);
 static DEFINE_PER_CPU(int, hrtimer_interrupts_saved);
 static DEFINE_PER_CPU(bool, watchdog_hardlockup_warned);
@@ -1250,6 +1250,7 @@ static const struct ctl_table watchdog_s
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_ONE,
 	},
+#if defined(CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER)
 	{
 		.procname	= "hardlockup_sys_info",
 		.data		= &hardlockup_si_mask,
@@ -1257,6 +1258,7 @@ static const struct ctl_table watchdog_s
 		.mode		= 0644,
 		.proc_handler	= sysctl_sys_info_handler,
 	},
+#endif
 #ifdef CONFIG_SMP
 	{
 		.procname	= "hardlockup_all_cpu_backtrace",
Quoted 1 line

_

This patch makes some sense because the arch-specific watchdog does not support the sys_info interface. And it is better than nothing. definitely.

A better solution would be export the variable and handle it in arch/powerpc/kernel/watchdog.c.

It seems that powerpc is the only architecture which could define HAVE_HARDLOCKUP_DETECTOR_ARCH.

Feng, would you have time to look at it?

Best Regards,
Petr

#5 lore raw
In reply to Andrew Morton
Quoted 25 lines · Andrew Morton
Quoted 12 lines · On Wed, 3 Dec 2025 09:05:30 +0800 kernel test robot <[email protected]> wrote:
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   47b7b5e32bb7264b51b89186043e1ada4090b558
commit: a9af76a78760717361cccc884dc649e30db61c8b [9966/13055] watchdog: add sys_info sysctls to dump sys info on system lockup
config: powerpc64-randconfig-002-20251203 (https://download.01.org/0day-ci/archive/20251203/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 734a912d0f025559fcf76bde9aaaeb0383c1625a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251203/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

Quoted 6 lines

All warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

kernel/watchdog.c:74:22: warning: unused variable 'hardlockup_si_mask' [-Wunused-variable]

      74 | static unsigned long hardlockup_si_mask;
         |                      ^~~~~~~~~~~~~~~~~~

1 warning generated.

I'm testing the appended patch but it needs checking please.

The comment for hardlockup_si_mask says

Quoted 7 lines

* bitmask to control what kinds of system info to be printed when
* hard lockup is detected, it could be task, memory, lock etc.
* Refer include/linux/sys_info.h for detailed bit definition.

but the variable depends on "COUNTS_HRTIMER". The comment doesn't mention hrtimers and I don't see why it should. Not sure what's going on here.

Yes, it is a little weird. Logically the 'hardlockup_si_mask' should be under the CONFIG_HARDLOCKUP_DETECTOR, which is what my original patch did.

I did a quick check, and there are 3 types of hardlockup detector:

HARDLOCKUP_DETECTOR_PERF
HARDLOCKUP_DETECTOR_BUDDY
HARDLOCKUP_DETECTOR_ARCH

IIUC, most archs will use the first 2 types, which will both select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER (lib/Kconfig.debug), which is kind of a _proxy_ to select SOFTLOCKUP_DETECTOR which needs hrtimer for its implementations.

And only very few arch may chose the 3rd architecture specific implementation, which was in 0day bot's kernel config.

In arch/powerpc/Kconfig

	select HAVE_HARDLOCKUP_DETECTOR_ARCH	if PPC_BOOK3S_64 && SMP
	select HAVE_HARDLOCKUP_DETECTOR_PERF	if PERF_EVENTS && HAVE_PERF_EVENTS_NMI

In short, for most cases the hrtimer is used for soft/hard lockup detector.

Thanks,
Feng

#4 lore raw
In reply to Petr Mladek
Quoted 45 lines · Petr Mladek
Quoted 25 lines · Andrew Morton
Quoted 12 lines · On Wed, 3 Dec 2025 09:05:30 +0800 kernel test robot <[email protected]> wrote:
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   47b7b5e32bb7264b51b89186043e1ada4090b558
commit: a9af76a78760717361cccc884dc649e30db61c8b [9966/13055] watchdog: add sys_info sysctls to dump sys info on system lockup
config: powerpc64-randconfig-002-20251203 (https://download.01.org/0day-ci/archive/20251203/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 734a912d0f025559fcf76bde9aaaeb0383c1625a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251203/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

Quoted 6 lines

All warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

kernel/watchdog.c:74:22: warning: unused variable 'hardlockup_si_mask' [-Wunused-variable]

      74 | static unsigned long hardlockup_si_mask;
         |                      ^~~~~~~~~~~~~~~~~~

1 warning generated.

I'm testing the appended patch but it needs checking please.

The comment for hardlockup_si_mask says

Quoted 7 lines

* bitmask to control what kinds of system info to be printed when
* hard lockup is detected, it could be task, memory, lock etc.
* Refer include/linux/sys_info.h for detailed bit definition.

but the variable depends on "COUNTS_HRTIMER". The comment doesn't mention hrtimers and I don't see why it should. Not sure what's going on here.

Good point! It took me some time to understand it.

So, powerpc implements its own watchog, see arch/powerpc/kernel/watchdog.c. The watchdog is supported only by some powerpc platforms, see the
following line in arch/powerpc/Kconfig:

	select HAVE_HARDLOCKUP_DETECTOR_ARCH	if PPC_BOOK3S_64 && SMP

As a result, the test system could have the following in the config,
see https://download.01.org/0day-ci/archive/20251203/[email protected]/config

Quoted 6 lines

CONFIG_HARDLOCKUP_DETECTOR=y
# CONFIG_HARDLOCKUP_DETECTOR_PERF is not set # CONFIG_HARDLOCKUP_DETECTOR_BUDDY is not set CONFIG_HARDLOCKUP_DETECTOR_ARCH=y

And "COUNTS_HRTIMER" is not defined.

Thanks for the check!

Was working on a reply at the same time :)

Quoted 22 lines
Quoted 16 lines
kernel/watchdog.c renamed from kernel/watchdog.c~kernel-watchdogc-fix-unused-var-warning +2 -0
@@ -1250,6 +1250,7 @@ static const struct ctl_table watchdog_s
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_ONE,
 	},
+#if defined(CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER)
 	{
 		.procname	= "hardlockup_sys_info",
 		.data		= &hardlockup_si_mask,
@@ -1257,6 +1258,7 @@ static const struct ctl_table watchdog_s
 		.mode		= 0644,
 		.proc_handler	= sysctl_sys_info_handler,
 	},
+#endif
 #ifdef CONFIG_SMP
 	{
 		.procname	= "hardlockup_all_cpu_backtrace",
Quoted 1 line

_

This patch makes some sense because the arch-specific watchdog does not support the sys_info interface. And it is better than nothing. definitely.

Quoted 2 lines

A better solution would be export the variable and handle it in arch/powerpc/kernel/watchdog.c.

Yep!

Quoted 4 lines

It seems that powerpc is the only architecture which could define HAVE_HARDLOCKUP_DETECTOR_ARCH.

Feng, would you have time to look at it?

Sure.

Thanks,
Feng