[PATCH 1/2] cpumask: switch cpumap_print_to_pagebuf() to using scnprintf()
From: Yury Norov
Date: Tue May 19 2026 - 12:36:49 EST
In preparation for removing bitmap_print_to_pagebuf(), switch
cpumap_print_to_pagebuf() to using scnprintf("%*pbl").
Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>
---
include/linux/cpumask.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
There's ongoing discussion about moving the offset_in_page() out of mm.h to
a separate lightweight header [1] and bringing the rest_of_page() helper in
addition to offset_in_page(). If that happens, cpumask.h should include the
new header and drop opencoding part.
[1] https://lore.kernel.org/all/20260517123428.1181981-4-thorsten.blum@xxxxxxxxx/
[2] https://lore.kernel.org/all/20260304012717.201797-1-ynorov@xxxxxxxxxx/
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 80211900f373..d3cda0544954 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -13,8 +13,10 @@
#include <linux/cpumask_types.h>
#include <linux/gfp_types.h>
#include <linux/numa.h>
+#include <linux/sprintf.h>
#include <linux/threads.h>
#include <linux/types.h>
+#include <vdso/page.h>
#include <asm/bug.h>
@@ -1326,8 +1328,9 @@ static __always_inline bool cpu_dying(unsigned int cpu)
static __always_inline ssize_t
cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask)
{
- return bitmap_print_to_pagebuf(list, buf, cpumask_bits(mask),
- nr_cpu_ids);
+ /* Opencode offset_in_page(buf) to not include linux/mm.h */
+ return scnprintf(buf, PAGE_SIZE - ((unsigned long)buf & ~PAGE_MASK),
+ list ? "%*pbl\n" : "%*pb\n", cpumask_pr_args(mask));
}
/**
--
2.51.0