[PATCH 11/12] cpumask: switch cpumap_print_to_pagebuf() to using scnprintf()
Yury Norov
ynorov at nvidia.com
Thu Feb 19 10:14:03 PST 2026
In preparation for removing bitmap_print_to_pagebuf(), switch
cpumap_print_to_pagebuf() to using scnprintf("%*pbl").
Signed-off-by: Yury Norov <ynorov at nvidia.com>
---
include/linux/cpumask.h | 17 +----------------
lib/cpumask.c | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 80211900f373..02cae16c941a 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -1313,22 +1313,7 @@ static __always_inline bool cpu_dying(unsigned int cpu)
}
#endif /* NR_CPUS > BITS_PER_LONG */
-/**
- * cpumap_print_to_pagebuf - copies the cpumask into the buffer either
- * as comma-separated list of cpus or hex values of cpumask
- * @list: indicates whether the cpumap must be list
- * @mask: the cpumask to copy
- * @buf: the buffer to copy into
- *
- * Return: the length of the (null-terminated) @buf string, zero if
- * nothing is copied.
- */
-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);
-}
+ssize_t cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask);
/**
* cpumap_print_bitmask_to_buf - copies the cpumask into the buffer as
diff --git a/lib/cpumask.c b/lib/cpumask.c
index 5adb9874fbd0..f5148253da6d 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -166,3 +166,20 @@ unsigned int cpumask_any_distribute(const struct cpumask *srcp)
return next;
}
EXPORT_SYMBOL(cpumask_any_distribute);
+
+/**
+ * cpumap_print_to_pagebuf - copies the cpumask into the buffer either
+ * as comma-separated list of cpus or hex values of cpumask
+ * @list: indicates whether the cpumap must be list
+ * @mask: the cpumask to copy
+ * @buf: the buffer to copy into
+ *
+ * Return: the length of the (null-terminated) @buf string, zero if
+ * nothing is copied.
+ */
+ssize_t cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask)
+{
+ return scnprintf(buf, rest_of_page(buf),
+ list ? "%*pbl\n" : "%*pb\n", cpumask_pr_args(mask));
+}
+EXPORT_SYMBOL(cpumap_print_to_pagebuf);
--
2.43.0
More information about the linux-arm-kernel
mailing list