tick/nohz: avoid showing '(null)' if nohz_full= not set
PATCH 1/1 tick/nohz: avoid showing '(null)' if nohz_full= not set
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.
--- drivers/base/cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/base/cpu.c +3 -1
@@ -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
Signature · 1 line
2.49.0
Greg KH
maintainerQuoted 23 lines · Aaron Tomlin
In the context of
CONFIG_NO_HZ_FULL=y,tick_nohz_full_mask(of typecpumask_var_t) is initialised to 0. Memory is only allocated to the cpumask data structure, intick_nohz_full_setup(), when Linux kernel boot-time parameter "nohz_full=" is correctly specified (seehousekeeping_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 withprint_cpus_isolated()behaviour.Signed-off-by Aaron Tomlin <[email protected]>--- drivers/base/cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/base/cpu.c +0
-0
drivers/base/cpu.c static DEVICE_ATTR(isolated, 0444, print_cpus_isolated, NULL); · line 309
Quoted 7 lines
drivers/base/cpu.c +3
-1@@ -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
kernel test robot
build botkernel test robot noticed the following build warnings:
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/[email protected]/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/[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 >>):
>> 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
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki