public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tick/nohz: avoid showing '(null)' if nohz_full= not set
@ 2025-10-06  0:58 Aaron Tomlin
  2025-10-06  6:34 ` Greg KH
  2025-10-09 19:40 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Aaron Tomlin @ 2025-10-06  0:58 UTC (permalink / raw)
  To: gregkh, rafael, dakr; +Cc: riel, frederic, atomlin, linux-kernel

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-09 19:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-06  0:58 [PATCH] tick/nohz: avoid showing '(null)' if nohz_full= not set Aaron Tomlin
2025-10-06  6:34 ` Greg KH
2025-10-09 19:40 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox