drivers/base/cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
In the context of CONFIG_NO_HZ_FULL=y, tick_nohz_full_mask (of type
cpumask_var_t) is initialised to 0. Memory is only allocated to the cpumask
data structure, in tick_nohz_full_setup(), when Linux kernel boot-time
parameter "nohz_full=" is correctly specified (see housekeeping_setup()).
If "nohz_full=" is not set and an attempt is made to read
/sys/devices/system/cpu/nohz_full, '(null)' can be displayed:
❯ cat /sys/devices/system/cpu/nohz_full
(null)
This patch changes the output to print a newline (or 0x0A) instead of
'(null)', making it consistent with print_cpus_isolated() behaviour.
Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
---
drivers/base/cpu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index fa0a2eef93ac..f694b4b24d6c 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -304,7 +304,9 @@ static DEVICE_ATTR(isolated, 0444, print_cpus_isolated, NULL);
static ssize_t print_cpus_nohz_full(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(tick_nohz_full_mask));
+ return !tick_nohz_full_mask ?
+ sysfs_emit(buf, "\n") :
+ sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(tick_nohz_full_mask));
}
static DEVICE_ATTR(nohz_full, 0444, print_cpus_nohz_full, NULL);
#endif
--
2.49.0
Hi Aaron,
kernel test robot noticed the following build warnings:
[auto build test WARNING on driver-core/driver-core-testing]
[also build test WARNING on driver-core/driver-core-next driver-core/driver-core-linus linus/master v6.17 next-20251009]
[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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Aaron-Tomlin/tick-nohz-avoid-showing-null-if-nohz_full-not-set/20251009-142404
base: driver-core/driver-core-testing
patch link: https://lore.kernel.org/r/20251006005824.76187-1-atomlin%40atomlin.com
patch subject: [PATCH] tick/nohz: avoid showing '(null)' if nohz_full= not set
config: x86_64-randconfig-078-20251009 (https://download.01.org/0day-ci/archive/20251010/202510100304.IpfE7EKh-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251010/202510100304.IpfE7EKh-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510100304.IpfE7EKh-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/base/cpu.c:307:10: warning: address of array 'tick_nohz_full_mask' will always evaluate to 'true' [-Wpointer-bool-conversion]
307 | return !tick_nohz_full_mask ?
| ~^~~~~~~~~~~~~~~~~~~
1 warning generated.
vim +307 drivers/base/cpu.c
302
303 #ifdef CONFIG_NO_HZ_FULL
304 static ssize_t print_cpus_nohz_full(struct device *dev,
305 struct device_attribute *attr, char *buf)
306 {
> 307 return !tick_nohz_full_mask ?
308 sysfs_emit(buf, "\n") :
309 sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(tick_nohz_full_mask));
310 }
311 static DEVICE_ATTR(nohz_full, 0444, print_cpus_nohz_full, NULL);
312 #endif
313
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On Sun, Oct 05, 2025 at 08:58:24PM -0400, Aaron Tomlin wrote:
> In the context of CONFIG_NO_HZ_FULL=y, tick_nohz_full_mask (of type
> cpumask_var_t) is initialised to 0. Memory is only allocated to the cpumask
> data structure, in tick_nohz_full_setup(), when Linux kernel boot-time
> parameter "nohz_full=" is correctly specified (see housekeeping_setup()).
> If "nohz_full=" is not set and an attempt is made to read
> /sys/devices/system/cpu/nohz_full, '(null)' can be displayed:
>
> ❯ cat /sys/devices/system/cpu/nohz_full
> (null)
>
> This patch changes the output to print a newline (or 0x0A) instead of
> '(null)', making it consistent with print_cpus_isolated() behaviour.
>
> Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
> ---
> drivers/base/cpu.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> index fa0a2eef93ac..f694b4b24d6c 100644
> --- a/drivers/base/cpu.c
> +++ b/drivers/base/cpu.c
> @@ -304,7 +304,9 @@ static DEVICE_ATTR(isolated, 0444, print_cpus_isolated, NULL);
> static ssize_t print_cpus_nohz_full(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> - return sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(tick_nohz_full_mask));
> + return !tick_nohz_full_mask ?
> + sysfs_emit(buf, "\n") :
> + sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(tick_nohz_full_mask));
Please write out the if statement please.
thanks,
greg k-h
© 2016 - 2025 Red Hat, Inc.