* [PATCH 0/2] bitmap: drop bitmap_print_to_pagebuf()
@ 2026-05-19 16:30 Yury Norov
2026-05-19 16:30 ` [PATCH 1/2] cpumask: switch cpumap_print_to_pagebuf() to using scnprintf() Yury Norov
2026-05-19 16:30 ` [PATCH 2/2] bitmap: drop bitmap_print_to_pagebuf() Yury Norov
0 siblings, 2 replies; 4+ messages in thread
From: Yury Norov @ 2026-05-19 16:30 UTC (permalink / raw)
To: Yury Norov, Rasmus Villemoes, Andrew Morton, linux-kernel
Cc: Yury Norov, Thorsten Blum, Lorenzo Stoakes,
David Hildenbrand (Arm),
Andy Shevchenko, William Kucharski
bitmap_print_to_pagebuf() users are now all switched to more
straightforward alternative. The last one is cpumap_print_to_pagebuf()
helper in linux/cpumask.h.
Switch it to scnprintf(), and drop the bitmap_print_to_pagebuf().
Yury Norov (2):
cpumask: switch cpumap_print_to_pagebuf() to using scnprintf()
bitmap: drop bitmap_print_to_pagebuf()
include/linux/bitmap-str.h | 1 -
include/linux/cpumask.h | 7 +++++--
lib/bitmap-str.c | 42 +++++---------------------------------
3 files changed, 10 insertions(+), 40 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] cpumask: switch cpumap_print_to_pagebuf() to using scnprintf()
2026-05-19 16:30 [PATCH 0/2] bitmap: drop bitmap_print_to_pagebuf() Yury Norov
@ 2026-05-19 16:30 ` Yury Norov
2026-06-01 18:55 ` Andy Shevchenko
2026-05-19 16:30 ` [PATCH 2/2] bitmap: drop bitmap_print_to_pagebuf() Yury Norov
1 sibling, 1 reply; 4+ messages in thread
From: Yury Norov @ 2026-05-19 16:30 UTC (permalink / raw)
To: Yury Norov, Rasmus Villemoes, Andrew Morton, linux-kernel
Cc: Yury Norov, Thorsten Blum, Lorenzo Stoakes,
David Hildenbrand (Arm),
Andy Shevchenko, William Kucharski
In preparation for removing bitmap_print_to_pagebuf(), switch
cpumap_print_to_pagebuf() to using scnprintf("%*pbl").
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
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@linux.dev/
[2] https://lore.kernel.org/all/20260304012717.201797-1-ynorov@nvidia.com/
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] bitmap: drop bitmap_print_to_pagebuf()
2026-05-19 16:30 [PATCH 0/2] bitmap: drop bitmap_print_to_pagebuf() Yury Norov
2026-05-19 16:30 ` [PATCH 1/2] cpumask: switch cpumap_print_to_pagebuf() to using scnprintf() Yury Norov
@ 2026-05-19 16:30 ` Yury Norov
1 sibling, 0 replies; 4+ messages in thread
From: Yury Norov @ 2026-05-19 16:30 UTC (permalink / raw)
To: Yury Norov, Rasmus Villemoes, Andrew Morton, linux-kernel
Cc: Yury Norov, Thorsten Blum, Lorenzo Stoakes,
David Hildenbrand (Arm),
Andy Shevchenko, William Kucharski
Now that all users of bitmap_print_to_pagebuf() are switched to the
alternatives, drop the function.
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
include/linux/bitmap-str.h | 1 -
lib/bitmap-str.c | 42 +++++---------------------------------
2 files changed, 5 insertions(+), 38 deletions(-)
diff --git a/include/linux/bitmap-str.h b/include/linux/bitmap-str.h
index 53d3e1b32d3d..abe7a69a846f 100644
--- a/include/linux/bitmap-str.h
+++ b/include/linux/bitmap-str.h
@@ -5,7 +5,6 @@
#include <linux/types.h>
int bitmap_parse_user(const char __user *ubuf, unsigned int ulen, unsigned long *dst, int nbits);
-int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp, int nmaskbits);
int bitmap_print_bitmask_to_buf(char *buf, const unsigned long *maskp, int nmaskbits,
loff_t off, size_t count);
int bitmap_print_list_to_buf(char *buf, const unsigned long *maskp, int nmaskbits,
diff --git a/lib/bitmap-str.c b/lib/bitmap-str.c
index be745209507a..bbdb2e9ff2c2 100644
--- a/lib/bitmap-str.c
+++ b/lib/bitmap-str.c
@@ -39,32 +39,6 @@ int bitmap_parse_user(const char __user *ubuf,
}
EXPORT_SYMBOL(bitmap_parse_user);
-/**
- * bitmap_print_to_pagebuf - convert bitmap to list or hex format ASCII string
- * @list: indicates whether the bitmap must be list
- * @buf: page aligned buffer into which string is placed
- * @maskp: pointer to bitmap to convert
- * @nmaskbits: size of bitmap, in bits
- *
- * Output format is a comma-separated list of decimal numbers and
- * ranges if list is specified or hex digits grouped into comma-separated
- * sets of 8 digits/set. Returns the number of characters written to buf.
- *
- * It is assumed that @buf is a pointer into a PAGE_SIZE, page-aligned
- * area and that sufficient storage remains at @buf to accommodate the
- * bitmap_print_to_pagebuf() output. Returns the number of characters
- * actually printed to @buf, excluding terminating '\0'.
- */
-int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
- int nmaskbits)
-{
- ptrdiff_t len = PAGE_SIZE - offset_in_page(buf);
-
- return list ? scnprintf(buf, len, "%*pbl\n", nmaskbits, maskp) :
- scnprintf(buf, len, "%*pb\n", nmaskbits, maskp);
-}
-EXPORT_SYMBOL(bitmap_print_to_pagebuf);
-
/**
* bitmap_print_to_buf - convert bitmap to list or hex format ASCII string
* @list: indicates whether the bitmap must be list
@@ -101,7 +75,7 @@ static int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
* @off: in the string from which we are copying, We copy to @buf
* @count: the maximum number of bytes to print
*
- * The bitmap_print_to_pagebuf() is used indirectly via its cpumap wrapper
+ * The sprintf("%*pb[l]") is used indirectly via its cpumap wrapper
* cpumap_print_to_pagebuf() or directly by drivers to export hexadecimal
* bitmask and decimal list to userspace by sysfs ABI.
* Drivers might be using a normal attribute for this kind of ABIs. A
@@ -111,18 +85,11 @@ static int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
* struct device_attribute *attr, char *buf)
* {
* ...
- * return bitmap_print_to_pagebuf(true, buf, &mask, nr_trig_max);
+ * return scnprintf(buf, PAGE_SIZE - offset_in_page(buf), nr_trig_max, &mask);
* }
*
* show entry of attribute has no offset and count parameters and this
* means the file is limited to one page only.
- * bitmap_print_to_pagebuf() API works terribly well for this kind of
- * normal attribute with buf parameter and without offset, count::
- *
- * bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
- * int nmaskbits)
- * {
- * }
*
* The problem is once we have a large bitmap, we have a chance to get a
* bitmask or list more than one page. Especially for list, it could be
@@ -149,7 +116,7 @@ static int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
*
* The role of cpumap_print_bitmask_to_buf() and cpumap_print_list_to_buf()
* is similar with cpumap_print_to_pagebuf(), the difference is that
- * bitmap_print_to_pagebuf() mainly serves sysfs attribute with the assumption
+ * scnprintf("%*pb[l]") mainly serves sysfs attribute with the assumption
* the destination buffer is exactly one page and won't be more than one page.
* cpumap_print_bitmask_to_buf() and cpumap_print_list_to_buf(), on the other
* hand, mainly serves bin_attribute which doesn't work with exact one page,
@@ -158,7 +125,8 @@ static int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
*
* WARNING!
*
- * This function is not a replacement for sprintf() or bitmap_print_to_pagebuf().
+ * This function is not a replacement for sprintf().
+ *
* It is intended to workaround sysfs limitations discussed above and should be
* used carefully in general case for the following reasons:
*
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] cpumask: switch cpumap_print_to_pagebuf() to using scnprintf()
2026-05-19 16:30 ` [PATCH 1/2] cpumask: switch cpumap_print_to_pagebuf() to using scnprintf() Yury Norov
@ 2026-06-01 18:55 ` Andy Shevchenko
0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-06-01 18:55 UTC (permalink / raw)
To: Yury Norov
Cc: Yury Norov, Rasmus Villemoes, Andrew Morton, linux-kernel,
Thorsten Blum, Lorenzo Stoakes, David Hildenbrand (Arm),
William Kucharski
On Tue, May 19, 2026 at 12:30:56PM -0400, Yury Norov wrote:
> In preparation for removing bitmap_print_to_pagebuf(), switch
> cpumap_print_to_pagebuf() to using scnprintf("%*pbl").
...
> +#include <vdso/page.h>
Shouldn't this be rather asm/page.h?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-01 18:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-19 16:30 [PATCH 0/2] bitmap: drop bitmap_print_to_pagebuf() Yury Norov
2026-05-19 16:30 ` [PATCH 1/2] cpumask: switch cpumap_print_to_pagebuf() to using scnprintf() Yury Norov
2026-06-01 18:55 ` Andy Shevchenko
2026-05-19 16:30 ` [PATCH 2/2] bitmap: drop bitmap_print_to_pagebuf() Yury Norov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®