public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] cleanup bitmaps printing in sysfs
@ 2026-02-19 18:13 Yury Norov
  2026-02-19 18:13 ` [PATCH 01/12] powerpc/xive: simplify xive_spapr_debug_show() Yury Norov
                   ` (12 more replies)
  0 siblings, 13 replies; 19+ messages in thread
From: Yury Norov @ 2026-02-19 18:13 UTC (permalink / raw)
  To: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev
  Cc: Yury Norov

Bitmap API has a bitmap_print_to_pagebuf() function that is intended to
print bitmap into a human readable format, making sure that the output
string will not get big enough to cross the current page limit.

Some drivers use this function immediately before passing the result to
seq_printf() with no modification. This is useless because seq_pritf()
takes care of not overflowing the buffer by itself, and perfectly prints
bitmaps with "%*pb[l]".

The first 6 patches of the series convert such bitmap_print_to_pagebuf()
users to just print the bitmap with seq_printf().

Patch #7 adds (actually moves from net/p9 driver) a handy macro
rest_of_page() and applies it globally.

The rest of the series switches all other users to scnprintf("%*pb[l]"),
so that users wont abuse kmalloc() + bitmap_print_to_pagebuf().

Patches 1-6 may be applied individually, or together with the rest of
the series, at maintainers' discretion.

Yury Norov (12):
  powerpc/xive: simplify xive_spapr_debug_show()
  octeontx2-af: siplify rvu_debugfs
  thermal: intel: switch cpumask_get() to using
    cpumask_print_to_pagebuf()
  lib/prime_numbers: drop temporary buffer in dump_primes()
  bitmap: switch test to scnprintf("%*pbl")
  bitmap: align test_bitmap output
  mm: add rest_of_page() macro
  coresight: don't use bitmap_print_to_pagebuf()
  fpga: m10bmc-sec: switch show_canceled_csk() to using scnprintf()
  net-sysfs: switch xps_queue_show() to using scnprintf()
  cpumask: switch cpumap_print_to_pagebuf() to using scnprintf()
  bitmap: drop bitmap_print_to_pagebuf()

 arch/arm64/kernel/patching.c                  |  4 +-
 arch/powerpc/lib/code-patching.c              |  6 +--
 arch/powerpc/sysdev/xive/spapr.c              | 12 +-----
 arch/riscv/kernel/sbi.c                       |  4 +-
 arch/s390/kvm/gaccess.c                       |  6 +--
 arch/x86/kvm/emulate.c                        |  4 +-
 drivers/block/null_blk/main.c                 |  6 +--
 drivers/fpga/intel-m10-bmc-sec-update.c       |  3 +-
 drivers/gpu/drm/i915/gt/shmem_utils.c         |  5 +--
 .../hwtracing/coresight/coresight-cti-sysfs.c | 33 +++++++--------
 drivers/md/dm-pcache/backing_dev.h            |  2 +-
 .../marvell/octeontx2/af/rvu_debugfs.c        | 28 +++----------
 drivers/net/ethernet/meta/fbnic/fbnic_tlv.c   |  6 +--
 drivers/s390/net/qeth_core_main.c             |  6 +--
 drivers/spi/spi-pl022.c                       |  3 +-
 drivers/spi/spi.c                             |  4 +-
 drivers/thermal/intel/intel_powerclamp.c      |  3 +-
 fs/ext4/verity.c                              |  3 +-
 fs/f2fs/verity.c                              |  6 +--
 fs/fuse/dev.c                                 |  4 +-
 fs/iomap/buffered-io.c                        |  2 +-
 fs/nfs/pagelist.c                             |  2 +-
 fs/remap_range.c                              |  3 +-
 fs/xfs/scrub/xfile.c                          |  3 +-
 include/crypto/scatterwalk.h                  |  2 +-
 include/linux/bitmap-str.h                    |  1 -
 include/linux/cpumask.h                       | 17 +-------
 include/linux/highmem.h                       | 24 +++++------
 include/linux/iomap.h                         |  2 +-
 include/linux/iov_iter.h                      |  3 +-
 include/linux/mm.h                            |  2 +
 kernel/events/ring_buffer.c                   |  2 +-
 lib/bitmap-str.c                              | 42 +++----------------
 lib/cpumask.c                                 | 17 ++++++++
 lib/iov_iter.c                                |  5 +--
 lib/math/tests/prime_numbers_kunit.c          |  6 +--
 lib/test_bitmap.c                             | 17 ++++----
 net/9p/trans_virtio.c                         |  6 ---
 net/core/net-sysfs.c                          |  2 +-
 sound/virtio/virtio_pcm_msg.c                 |  4 +-
 40 files changed, 111 insertions(+), 199 deletions(-)

-- 
2.43.0


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

* [PATCH 01/12] powerpc/xive: simplify xive_spapr_debug_show()
  2026-02-19 18:13 [PATCH 00/12] cleanup bitmaps printing in sysfs Yury Norov
@ 2026-02-19 18:13 ` Yury Norov
  2026-02-23 13:13   ` Shrikanth Hegde
  2026-02-19 18:13 ` [PATCH 02/12] octeontx2-af: siplify rvu_debugfs Yury Norov
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Yury Norov @ 2026-02-19 18:13 UTC (permalink / raw)
  To: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev
  Cc: Yury Norov

The function creates temporary buffer to convert xibm->bitmap to a
human-readable list before passing it to seq_printf. Drop it and print
the list in seq_printf() directly with the "%*pbl" specifier.

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 arch/powerpc/sysdev/xive/spapr.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/sysdev/xive/spapr.c b/arch/powerpc/sysdev/xive/spapr.c
index 5aedbe3e8e6a..f818299579b1 100644
--- a/arch/powerpc/sysdev/xive/spapr.c
+++ b/arch/powerpc/sysdev/xive/spapr.c
@@ -667,17 +667,9 @@ static void xive_spapr_sync_source(u32 hw_irq)
 static int xive_spapr_debug_show(struct seq_file *m, void *private)
 {
 	struct xive_irq_bitmap *xibm;
-	char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
 
-	if (!buf)
-		return -ENOMEM;
-
-	list_for_each_entry(xibm, &xive_irq_bitmaps, list) {
-		memset(buf, 0, PAGE_SIZE);
-		bitmap_print_to_pagebuf(true, buf, xibm->bitmap, xibm->count);
-		seq_printf(m, "bitmap #%d: %s", xibm->count, buf);
-	}
-	kfree(buf);
+	list_for_each_entry(xibm, &xive_irq_bitmaps, list)
+		seq_printf(m, "bitmap #%d: %*pbl\n", xibm->count, xibm->count, xibm->bitmap);
 
 	return 0;
 }
-- 
2.43.0


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

* [PATCH 02/12] octeontx2-af: siplify rvu_debugfs
  2026-02-19 18:13 [PATCH 00/12] cleanup bitmaps printing in sysfs Yury Norov
  2026-02-19 18:13 ` [PATCH 01/12] powerpc/xive: simplify xive_spapr_debug_show() Yury Norov
@ 2026-02-19 18:13 ` Yury Norov
  2026-02-19 18:13 ` [PATCH 03/12] thermal: intel: switch cpumask_get() to using cpumask_print_to_pagebuf() Yury Norov
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Yury Norov @ 2026-02-19 18:13 UTC (permalink / raw)
  To: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev
  Cc: Yury Norov

The driver uses bitmap_print_to_pagebuf() to store human-readable
bitmaps representations in a temporary buffers; and then feed
seq_printf() with it.

Switch to using seq_printf("%*pb") directly and drop intermediate
buffer.

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 .../marvell/octeontx2/af/rvu_debugfs.c        | 28 ++++---------------
 1 file changed, 5 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
index 15d3cb0b9da6..93039feace4f 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
@@ -960,30 +960,21 @@ static bool rvu_dbg_is_valid_lf(struct rvu *rvu, int blkaddr, int lf,
 
 static void print_npa_qsize(struct seq_file *m, struct rvu_pfvf *pfvf)
 {
-	char *buf;
-
-	buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-	if (!buf)
-		return;
-
 	if (!pfvf->aura_ctx) {
 		seq_puts(m, "Aura context is not initialized\n");
 	} else {
-		bitmap_print_to_pagebuf(false, buf, pfvf->aura_bmap,
-					pfvf->aura_ctx->qsize);
 		seq_printf(m, "Aura count : %d\n", pfvf->aura_ctx->qsize);
-		seq_printf(m, "Aura context ena/dis bitmap : %s\n", buf);
+		seq_printf(m, "Aura context ena/dis bitmap : %*pb\n",
+			   pfvf->aura_ctx->qsize, pfvf->aura_bmap);
 	}
 
 	if (!pfvf->pool_ctx) {
 		seq_puts(m, "Pool context is not initialized\n");
 	} else {
-		bitmap_print_to_pagebuf(false, buf, pfvf->pool_bmap,
-					pfvf->pool_ctx->qsize);
 		seq_printf(m, "Pool count : %d\n", pfvf->pool_ctx->qsize);
-		seq_printf(m, "Pool context ena/dis bitmap : %s\n", buf);
+		seq_printf(m, "Pool context ena/dis bitmap : %*pb\n",
+			   pfvf->aura_ctx->qsize, pfvf->aura_bmap);
 	}
-	kfree(buf);
 }
 
 /* The 'qsize' entry dumps current Aura/Pool context Qsize
@@ -2545,17 +2536,8 @@ RVU_DEBUG_SEQ_FOPS(nix_cq_ctx, nix_cq_ctx_display, nix_cq_ctx_write);
 static void print_nix_qctx_qsize(struct seq_file *filp, int qsize,
 				 unsigned long *bmap, char *qtype)
 {
-	char *buf;
-
-	buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-	if (!buf)
-		return;
-
-	bitmap_print_to_pagebuf(false, buf, bmap, qsize);
 	seq_printf(filp, "%s context count : %d\n", qtype, qsize);
-	seq_printf(filp, "%s context ena/dis bitmap : %s\n",
-		   qtype, buf);
-	kfree(buf);
+	seq_printf(filp, "%s context ena/dis bitmap : %*pb\n", qtype, qsize, bmap);
 }
 
 static void print_nix_qsize(struct seq_file *filp, struct rvu_pfvf *pfvf)
-- 
2.43.0


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

* [PATCH 03/12] thermal: intel: switch cpumask_get() to using cpumask_print_to_pagebuf()
  2026-02-19 18:13 [PATCH 00/12] cleanup bitmaps printing in sysfs Yury Norov
  2026-02-19 18:13 ` [PATCH 01/12] powerpc/xive: simplify xive_spapr_debug_show() Yury Norov
  2026-02-19 18:13 ` [PATCH 02/12] octeontx2-af: siplify rvu_debugfs Yury Norov
@ 2026-02-19 18:13 ` Yury Norov
  2026-02-19 18:13 ` [PATCH 04/12] lib/prime_numbers: drop temporary buffer in dump_primes() Yury Norov
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Yury Norov @ 2026-02-19 18:13 UTC (permalink / raw)
  To: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev
  Cc: Yury Norov

The function opencodes cpumask_print_to_pagebuf() with more generic
bitmap_print_to_pagebuf(). Switch to using the proper API.

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 drivers/thermal/intel/intel_powerclamp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c
index 9a4cec000910..ccf380da12f2 100644
--- a/drivers/thermal/intel/intel_powerclamp.c
+++ b/drivers/thermal/intel/intel_powerclamp.c
@@ -200,8 +200,7 @@ static int cpumask_get(char *buf, const struct kernel_param *kp)
 	if (!cpumask_available(idle_injection_cpu_mask))
 		return -ENODEV;
 
-	return bitmap_print_to_pagebuf(false, buf, cpumask_bits(idle_injection_cpu_mask),
-				       nr_cpumask_bits);
+	return cpumap_print_to_pagebuf(false, buf, idle_injection_cpu_mask);
 }
 
 static const struct kernel_param_ops cpumask_ops = {
-- 
2.43.0


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

* [PATCH 04/12] lib/prime_numbers: drop temporary buffer in dump_primes()
  2026-02-19 18:13 [PATCH 00/12] cleanup bitmaps printing in sysfs Yury Norov
                   ` (2 preceding siblings ...)
  2026-02-19 18:13 ` [PATCH 03/12] thermal: intel: switch cpumask_get() to using cpumask_print_to_pagebuf() Yury Norov
@ 2026-02-19 18:13 ` Yury Norov
  2026-02-19 18:13 ` [PATCH 05/12] bitmap: switch test to scnprintf("%*pbl") Yury Norov
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Yury Norov @ 2026-02-19 18:13 UTC (permalink / raw)
  To: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev
  Cc: Yury Norov

The function uses temporary buffer to convert primes bitmap into
human readable format. Switch to using kunit_info("%*pbl")", and
drop the buffer.

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 lib/math/tests/prime_numbers_kunit.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/math/tests/prime_numbers_kunit.c b/lib/math/tests/prime_numbers_kunit.c
index 2f1643208c66..55ac160c6dfa 100644
--- a/lib/math/tests/prime_numbers_kunit.c
+++ b/lib/math/tests/prime_numbers_kunit.c
@@ -8,12 +8,10 @@
 
 static void dump_primes(void *ctx, const struct primes *p)
 {
-	static char buf[PAGE_SIZE];
 	struct kunit_suite *suite = ctx;
 
-	bitmap_print_to_pagebuf(true, buf, p->primes, p->sz);
-	kunit_info(suite, "primes.{last=%lu, .sz=%lu, .primes[]=...x%lx} = %s",
-		   p->last, p->sz, p->primes[BITS_TO_LONGS(p->sz) - 1], buf);
+	kunit_info(suite, "primes.{last=%lu, .sz=%lu, .primes[]=...x%lx} = %*pbl",
+		   p->last, p->sz, p->primes[BITS_TO_LONGS(p->sz) - 1], (int)p->sz, p->primes);
 }
 
 static void prime_numbers_test(struct kunit *test)
-- 
2.43.0


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

* [PATCH 05/12] bitmap: switch test to scnprintf("%*pbl")
  2026-02-19 18:13 [PATCH 00/12] cleanup bitmaps printing in sysfs Yury Norov
                   ` (3 preceding siblings ...)
  2026-02-19 18:13 ` [PATCH 04/12] lib/prime_numbers: drop temporary buffer in dump_primes() Yury Norov
@ 2026-02-19 18:13 ` Yury Norov
  2026-02-19 18:13 ` [PATCH 06/12] bitmap: align test_bitmap output Yury Norov
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Yury Norov @ 2026-02-19 18:13 UTC (permalink / raw)
  To: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev
  Cc: Yury Norov

scnprintf("%*pbl") is more verbose than bitmap_print_to_pagebuf().
Switch the test to using it. This also improves the test output
because bitmap_print_to_pagebuf() adds \n at the end of the printed
bitmap, which breaks the test format.

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
The following patch adds more beautifications to the test outputs and
shows the before/after.

 lib/test_bitmap.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index c83829ef557f..2d9b71ad455c 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -544,22 +544,22 @@ static void __init test_bitmap_printlist(void)
 		goto out;
 
 	time = ktime_get();
-	ret = bitmap_print_to_pagebuf(true, buf, bmap, PAGE_SIZE * 8);
+	ret = scnprintf(buf, PAGE_SIZE, "%*pbl", (int)PAGE_SIZE * 8, bmap);
 	time = ktime_get() - time;
 
-	if (ret != slen + 1) {
-		pr_err("bitmap_print_to_pagebuf: result is %d, expected %d\n", ret, slen);
+	if (ret != slen) {
+		pr_err("bitmap_printlist: result is %d, expected %d\n", ret, slen);
 		failed_tests++;
 		goto out;
 	}
 
 	if (strncmp(buf, expected, slen)) {
-		pr_err("bitmap_print_to_pagebuf: result is %s, expected %s\n", buf, expected);
+		pr_err("bitmap_printlist: result is %s, expected %s\n", buf, expected);
 		failed_tests++;
 		goto out;
 	}
 
-	pr_info("bitmap_print_to_pagebuf: input is '%s', Time: %llu\n", buf, time);
+	pr_info("bitmap_printlist: input is '%s', Time: %llu\n", buf, time);
 out:
 	kfree(buf);
 	kfree(bmap);
-- 
2.43.0


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

* [PATCH 06/12] bitmap: align test_bitmap output
  2026-02-19 18:13 [PATCH 00/12] cleanup bitmaps printing in sysfs Yury Norov
                   ` (4 preceding siblings ...)
  2026-02-19 18:13 ` [PATCH 05/12] bitmap: switch test to scnprintf("%*pbl") Yury Norov
@ 2026-02-19 18:13 ` Yury Norov
  2026-02-19 18:13 ` [PATCH 07/12] mm: add rest_of_page() macro Yury Norov
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Yury Norov @ 2026-02-19 18:13 UTC (permalink / raw)
  To: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev
  Cc: Yury Norov

Different subtests print output in slightly different formats. Unify the
format for better visual representation.

The test output before:

[    0.553474] test_bitmap: parselist: 14: input is '0-2047:128/256' OK, Time: 202
[    0.555121] test_bitmap: bitmap_print_to_pagebuf: input is '0-32767
[    0.555121] ', Time: 1278
[    0.578392] test_bitmap: Time spent in test_bitmap_read_perf:	427864
[    0.580137] test_bitmap: Time spent in test_bitmap_write_perf:	793554
[    0.581957] test_bitmap: all 390447 tests passed

And after:

[    0.314982] test_bitmap: parselist('0-2047:128/256'):	135
[    0.315517] test_bitmap: scnprintf("%*pbl", '0-32767'):	342
[    0.330045] test_bitmap: test_bitmap_read_perf:		252294
[    0.331132] test_bitmap: test_bitmap_write_perf:		539001
[    0.332163] test_bitmap: all 390447 tests passed

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 lib/test_bitmap.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index 2d9b71ad455c..2eed21bf4346 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -520,8 +520,7 @@ static void __init test_bitmap_parselist(void)
 		}
 
 		if (ptest.flags & PARSE_TIME)
-			pr_info("parselist: %d: input is '%s' OK, Time: %llu\n",
-					i, ptest.in, time);
+			pr_info("parselist('%s'):\t%llu\n", ptest.in, time);
 
 #undef ptest
 	}
@@ -548,18 +547,18 @@ static void __init test_bitmap_printlist(void)
 	time = ktime_get() - time;
 
 	if (ret != slen) {
-		pr_err("bitmap_printlist: result is %d, expected %d\n", ret, slen);
+		pr_err("scnprintf(\"%%*pbl\"): result is %d, expected %d\n", ret, slen);
 		failed_tests++;
 		goto out;
 	}
 
 	if (strncmp(buf, expected, slen)) {
-		pr_err("bitmap_printlist: result is %s, expected %s\n", buf, expected);
+		pr_err("scnprintf(\"%%*pbl\"): result is %s, expected %s\n", buf, expected);
 		failed_tests++;
 		goto out;
 	}
 
-	pr_info("bitmap_printlist: input is '%s', Time: %llu\n", buf, time);
+	pr_info("scnprintf(\"%%*pbl\", '%s'):\t%llu\n", buf, time);
 out:
 	kfree(buf);
 	kfree(bmap);
@@ -1395,7 +1394,7 @@ static void __init test_bitmap_read_perf(void)
 		}
 	}
 	time = ktime_get() - time;
-	pr_info("Time spent in %s:\t%llu\n", __func__, time);
+	pr_info("%s:\t\t%llu\n", __func__, time);
 }
 
 static void __init test_bitmap_write_perf(void)
@@ -1417,7 +1416,7 @@ static void __init test_bitmap_write_perf(void)
 		}
 	}
 	time = ktime_get() - time;
-	pr_info("Time spent in %s:\t%llu\n", __func__, time);
+	pr_info("%s:\t\t%llu\n", __func__, time);
 }
 
 #undef TEST_BIT_LEN
-- 
2.43.0


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

* [PATCH 07/12] mm: add rest_of_page() macro
  2026-02-19 18:13 [PATCH 00/12] cleanup bitmaps printing in sysfs Yury Norov
                   ` (5 preceding siblings ...)
  2026-02-19 18:13 ` [PATCH 06/12] bitmap: align test_bitmap output Yury Norov
@ 2026-02-19 18:13 ` Yury Norov
  2026-02-19 18:14 ` [PATCH 08/12] coresight: don't use bitmap_print_to_pagebuf() Yury Norov
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Yury Norov @ 2026-02-19 18:13 UTC (permalink / raw)
  To: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev
  Cc: Yury Norov

The net/9p networking driver adds a handy macro to calculate the
amount of bytes from a given pointer to the end of page. Move it
to mm, and use tree-wide.

No functional changes intended.

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 arch/arm64/kernel/patching.c                |  4 +---
 arch/powerpc/lib/code-patching.c            |  6 +++---
 arch/riscv/kernel/sbi.c                     |  4 ++--
 arch/s390/kvm/gaccess.c                     |  6 +++---
 arch/x86/kvm/emulate.c                      |  4 ++--
 drivers/block/null_blk/main.c               |  6 ++----
 drivers/gpu/drm/i915/gt/shmem_utils.c       |  5 ++---
 drivers/md/dm-pcache/backing_dev.h          |  2 +-
 drivers/net/ethernet/meta/fbnic/fbnic_tlv.c |  6 +++---
 drivers/s390/net/qeth_core_main.c           |  6 ++----
 drivers/spi/spi-pl022.c                     |  3 +--
 drivers/spi/spi.c                           |  4 +---
 fs/ext4/verity.c                            |  3 +--
 fs/f2fs/verity.c                            |  6 ++----
 fs/fuse/dev.c                               |  4 ++--
 fs/iomap/buffered-io.c                      |  2 +-
 fs/nfs/pagelist.c                           |  2 +-
 fs/remap_range.c                            |  3 +--
 fs/xfs/scrub/xfile.c                        |  3 +--
 include/crypto/scatterwalk.h                |  2 +-
 include/linux/highmem.h                     | 24 +++++++++------------
 include/linux/iomap.h                       |  2 +-
 include/linux/iov_iter.h                    |  3 +--
 include/linux/mm.h                          |  2 ++
 kernel/events/ring_buffer.c                 |  2 +-
 lib/bitmap-str.c                            |  2 +-
 lib/iov_iter.c                              |  5 ++---
 net/9p/trans_virtio.c                       |  6 ------
 sound/virtio/virtio_pcm_msg.c               |  4 ++--
 29 files changed, 53 insertions(+), 78 deletions(-)

diff --git a/arch/arm64/kernel/patching.c b/arch/arm64/kernel/patching.c
index 1041bc67a3ee..4c3a4401719b 100644
--- a/arch/arm64/kernel/patching.c
+++ b/arch/arm64/kernel/patching.c
@@ -116,9 +116,7 @@ static void *__text_poke(text_poke_f func, void *addr, void *src, size_t len)
 
 	while (patched < len) {
 		ptr = addr + patched;
-		size = min_t(size_t, PAGE_SIZE - offset_in_page(ptr),
-			     len - patched);
-
+		size = min_t(size_t, rest_of_page(ptr), len - patched);
 		waddr = patch_map(ptr, FIX_TEXT_POKE0);
 		func(waddr, src, patched, size);
 		patch_unmap(FIX_TEXT_POKE0);
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index f84e0337cc02..186a9cb79ee3 100644
--- a/arch/powerpc/lib/code-patching.c
+++ b/arch/powerpc/lib/code-patching.c
@@ -463,7 +463,7 @@ static int __patch_instructions(u32 *patch_addr, u32 *code, size_t len, bool rep
 
 /*
  * A page is mapped and instructions that fit the page are patched.
- * Assumes 'len' to be (PAGE_SIZE - offset_in_page(addr)) or below.
+ * Assumes 'len' to be rest_of_page(addr) or below.
  */
 static int __do_patch_instructions_mm(u32 *addr, u32 *code, size_t len, bool repeat_instr)
 {
@@ -514,7 +514,7 @@ static int __do_patch_instructions_mm(u32 *addr, u32 *code, size_t len, bool rep
 
 /*
  * A page is mapped and instructions that fit the page are patched.
- * Assumes 'len' to be (PAGE_SIZE - offset_in_page(addr)) or below.
+ * Assumes 'len' to be rest_of_page(addr) or below.
  */
 static int __do_patch_instructions(u32 *addr, u32 *code, size_t len, bool repeat_instr)
 {
@@ -554,7 +554,7 @@ int patch_instructions(u32 *addr, u32 *code, size_t len, bool repeat_instr)
 		size_t plen;
 		int err;
 
-		plen = min_t(size_t, PAGE_SIZE - offset_in_page(addr), len);
+		plen = min_t(size_t, rest_of_page(addr), len);
 
 		local_irq_save(flags);
 		if (mm_patch_enabled())
diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
index c443337056ab..9a2f656f776f 100644
--- a/arch/riscv/kernel/sbi.c
+++ b/arch/riscv/kernel/sbi.c
@@ -602,7 +602,7 @@ int sbi_debug_console_write(const char *bytes, unsigned int num_bytes)
 	else
 		base_addr = __pa(bytes);
 	if (PAGE_SIZE < (offset_in_page(bytes) + num_bytes))
-		num_bytes = PAGE_SIZE - offset_in_page(bytes);
+		num_bytes = rest_of_page(bytes);
 
 	if (IS_ENABLED(CONFIG_32BIT))
 		ret = sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_WRITE,
@@ -631,7 +631,7 @@ int sbi_debug_console_read(char *bytes, unsigned int num_bytes)
 	else
 		base_addr = __pa(bytes);
 	if (PAGE_SIZE < (offset_in_page(bytes) + num_bytes))
-		num_bytes = PAGE_SIZE - offset_in_page(bytes);
+		num_bytes = rest_of_page(bytes);
 
 	if (IS_ENABLED(CONFIG_32BIT))
 		ret = sbi_ecall(SBI_EXT_DBCN, SBI_EXT_DBCN_CONSOLE_READ,
diff --git a/arch/s390/kvm/gaccess.c b/arch/s390/kvm/gaccess.c
index 4630b2a067ea..40f85b7eca63 100644
--- a/arch/s390/kvm/gaccess.c
+++ b/arch/s390/kvm/gaccess.c
@@ -973,7 +973,7 @@ int access_guest_with_key(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar,
 	if (rc)
 		goto out_unlock;
 	for (idx = 0; idx < nr_pages; idx++) {
-		fragment_len = min(PAGE_SIZE - offset_in_page(gpas[idx]), len);
+		fragment_len = min(rest_of_page(gpas[idx]), len);
 		if (try_fetch_prot_override && fetch_prot_override_applies(ga, fragment_len)) {
 			rc = access_guest_page_gpa(vcpu->kvm, mode, gpas[idx], data, fragment_len);
 		} else {
@@ -1015,7 +1015,7 @@ int access_guest_real(struct kvm_vcpu *vcpu, unsigned long gra,
 
 	while (len && !rc) {
 		gpa = kvm_s390_real_to_abs(vcpu, gra);
-		fragment_len = min(PAGE_SIZE - offset_in_page(gpa), len);
+		fragment_len = min(rest_of_page(gpa), len);
 		rc = access_guest_page_gpa(vcpu->kvm, mode, gpa, data, fragment_len);
 		len -= fragment_len;
 		gra += fragment_len;
@@ -1237,7 +1237,7 @@ int check_gpa_range(struct kvm *kvm, unsigned long gpa, unsigned long length,
 	int rc = 0;
 
 	while (length && !rc) {
-		fragment_len = min(PAGE_SIZE - offset_in_page(gpa), length);
+		fragment_len = min(rest_of_page(gpa), length);
 		rc = vm_check_access_key_gpa(kvm, access_key, mode, gpa);
 		length -= fragment_len;
 		gpa += fragment_len;
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index c8e292e9a24d..292a84e97a8a 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -864,7 +864,7 @@ static int __do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt, int op_size)
 		return rc;
 
 	size = min_t(unsigned, 15UL ^ cur_size, max_size);
-	size = min_t(unsigned, size, PAGE_SIZE - offset_in_page(linear));
+	size = min_t(unsigned int, size, rest_of_page(linear));
 
 	/*
 	 * One instruction can only straddle two pages,
@@ -1372,7 +1372,7 @@ static int pio_in_emulated(struct x86_emulate_ctxt *ctxt,
 			address_mask(ctxt, reg_read(ctxt, VCPU_REGS_RCX)) : 1;
 		in_page = (ctxt->eflags & X86_EFLAGS_DF) ?
 			offset_in_page(reg_read(ctxt, VCPU_REGS_RDI)) :
-			PAGE_SIZE - offset_in_page(reg_read(ctxt, VCPU_REGS_RDI));
+			rest_of_page(reg_read(ctxt, VCPU_REGS_RDI));
 		n = min3(in_page, (unsigned int)sizeof(rc->data) / size, count);
 		if (n == 0)
 			n = 1;
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 740a8ac42075..130fbcecedeb 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1147,8 +1147,7 @@ static blk_status_t copy_to_nullb(struct nullb *nullb, void *source,
 	sector_t sector;
 
 	while (count < n) {
-		temp = min3(nullb->dev->blocksize, n - count,
-			    PAGE_SIZE - offset_in_page(pos));
+		temp = min3(nullb->dev->blocksize, n - count, rest_of_page(pos));
 		sector = pos >> SECTOR_SHIFT;
 
 		if (null_cache_active(nullb) && !is_fua)
@@ -1181,8 +1180,7 @@ static void copy_from_nullb(struct nullb *nullb, void *dest, loff_t pos,
 	sector_t sector;
 
 	while (count < n) {
-		temp = min3(nullb->dev->blocksize, n - count,
-			    PAGE_SIZE - offset_in_page(pos));
+		temp = min3(nullb->dev->blocksize, n - count, rest_of_page(pos));
 		sector = pos >> SECTOR_SHIFT;
 
 		t_page = null_lookup_page(nullb, sector, false,
diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c
index 365c4b8b04f4..f56092acd233 100644
--- a/drivers/gpu/drm/i915/gt/shmem_utils.c
+++ b/drivers/gpu/drm/i915/gt/shmem_utils.c
@@ -98,8 +98,7 @@ static int __shmem_rw(struct file *file, loff_t off,
 	unsigned long pfn;
 
 	for (pfn = off >> PAGE_SHIFT; len; pfn++) {
-		unsigned int this =
-			min_t(size_t, PAGE_SIZE - offset_in_page(off), len);
+		unsigned int this = min_t(size_t, rest_of_page(off), len);
 		struct page *page;
 		void *vaddr;
 
@@ -134,7 +133,7 @@ int shmem_read_to_iosys_map(struct file *file, loff_t off,
 
 	for (pfn = off >> PAGE_SHIFT; len; pfn++) {
 		unsigned int this =
-			min_t(size_t, PAGE_SIZE - offset_in_page(off), len);
+			min_t(size_t, rest_of_page(off), len);
 		struct page *page;
 		void *vaddr;
 
diff --git a/drivers/md/dm-pcache/backing_dev.h b/drivers/md/dm-pcache/backing_dev.h
index b371cba483b9..17e83b38b845 100644
--- a/drivers/md/dm-pcache/backing_dev.h
+++ b/drivers/md/dm-pcache/backing_dev.h
@@ -96,7 +96,7 @@ static inline u32 backing_dev_req_coalesced_max_len(const void *data, u32 len)
 
 	first_page = vmalloc_to_page(p);
 advance:
-	in_page = PAGE_SIZE - offset_in_page(p);
+	in_page = rest_of_page(p);
 	to_advance = min_t(u32, in_page, len - done);
 
 	done += to_advance;
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_tlv.c b/drivers/net/ethernet/meta/fbnic/fbnic_tlv.c
index 517ed8b2f1cb..2e80c25ba3c8 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_tlv.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_tlv.c
@@ -52,7 +52,7 @@ struct fbnic_tlv_msg *fbnic_tlv_msg_alloc(u16 msg_id)
  **/
 int fbnic_tlv_attr_put_flag(struct fbnic_tlv_msg *msg, const u16 attr_id)
 {
-	int attr_max_len = PAGE_SIZE - offset_in_page(msg) - sizeof(*msg);
+	int attr_max_len = rest_of_page(msg) - sizeof(*msg);
 	struct fbnic_tlv_hdr hdr = { 0 };
 	struct fbnic_tlv_msg *attr;
 
@@ -94,7 +94,7 @@ int fbnic_tlv_attr_put_flag(struct fbnic_tlv_msg *msg, const u16 attr_id)
 int fbnic_tlv_attr_put_value(struct fbnic_tlv_msg *msg, const u16 attr_id,
 			     const void *value, const int len)
 {
-	int attr_max_len = PAGE_SIZE - offset_in_page(msg) - sizeof(*msg);
+	int attr_max_len = rest_of_page(msg) - sizeof(*msg);
 	struct fbnic_tlv_hdr hdr = { 0 };
 	struct fbnic_tlv_msg *attr;
 
@@ -292,7 +292,7 @@ ssize_t fbnic_tlv_attr_get_string(struct fbnic_tlv_msg *attr, char *dst,
 struct fbnic_tlv_msg *fbnic_tlv_attr_nest_start(struct fbnic_tlv_msg *msg,
 						u16 attr_id)
 {
-	int attr_max_len = PAGE_SIZE - offset_in_page(msg) - sizeof(*msg);
+	int attr_max_len = rest_of_page(msg) - sizeof(*msg);
 	struct fbnic_tlv_msg *attr = &msg[le16_to_cpu(msg->hdr.len)];
 	struct fbnic_tlv_hdr hdr = { 0 };
 
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 1c80e8ca67b5..1b983c397fa8 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -4087,8 +4087,7 @@ static unsigned int qeth_fill_buffer(struct qeth_qdio_out_buffer *buf,
 
 	/* map linear part into buffer element(s) */
 	while (length > 0) {
-		elem_length = min_t(unsigned int, length,
-				    PAGE_SIZE - offset_in_page(data));
+		elem_length = min_t(unsigned int, length, rest_of_page(data));
 
 		buffer->element[element].addr = virt_to_dma64(data);
 		buffer->element[element].length = elem_length;
@@ -4117,8 +4116,7 @@ static unsigned int qeth_fill_buffer(struct qeth_qdio_out_buffer *buf,
 		data = skb_frag_address(frag);
 		length = skb_frag_size(frag);
 		while (length > 0) {
-			elem_length = min_t(unsigned int, length,
-					    PAGE_SIZE - offset_in_page(data));
+			elem_length = min_t(unsigned int, length, rest_of_page(data));
 
 			buffer->element[element].addr = virt_to_dma64(data);
 			buffer->element[element].length = elem_length;
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index c32a1fba31ef..da44a37b22df 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -761,8 +761,7 @@ static void setup_dma_scatter(struct pl022 *pl022,
 			 * we just feed in this, else we stuff in as much
 			 * as we can.
 			 */
-			mapbytes = min_t(int, bytesleft,
-					 PAGE_SIZE - offset_in_page(bufp));
+			mapbytes = min_t(int, bytesleft, rest_of_page(bufp));
 
 			sg_set_page(sg, virt_to_page(bufp),
 				    mapbytes, offset_in_page(bufp));
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 3887fcf8ec86..ad23fad29b9d 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1162,9 +1162,7 @@ static int spi_map_buf_attrs(struct spi_controller *ctlr, struct device *dev,
 			 * the desc_len and the remaining buffer length that
 			 * fits in a page.
 			 */
-			min = min_t(size_t, desc_len,
-				    min_t(size_t, len,
-					  PAGE_SIZE - offset_in_page(buf)));
+			min = min_t(size_t, desc_len, min_t(size_t, len, rest_of_page(buf)));
 			if (vmalloced_buf)
 				vm_page = vmalloc_to_page(buf);
 			else
diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c
index ca61da53f313..3dc95581e4b1 100644
--- a/fs/ext4/verity.c
+++ b/fs/ext4/verity.c
@@ -74,8 +74,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count,
 		return -EFBIG;
 
 	while (count) {
-		size_t n = min_t(size_t, count,
-				 PAGE_SIZE - offset_in_page(pos));
+		size_t n = min_t(size_t, count, rest_of_page(pos));
 		struct folio *folio;
 		void *fsdata = NULL;
 		int res;
diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c
index 92ebcc19cab0..1c3403fbf2a8 100644
--- a/fs/f2fs/verity.c
+++ b/fs/f2fs/verity.c
@@ -44,8 +44,7 @@ static int pagecache_read(struct inode *inode, void *buf, size_t count,
 			  loff_t pos)
 {
 	while (count) {
-		size_t n = min_t(size_t, count,
-				 PAGE_SIZE - offset_in_page(pos));
+		size_t n = min_t(size_t, count, rest_of_page(pos));
 		struct page *page;
 
 		page = read_mapping_page(inode->i_mapping, pos >> PAGE_SHIFT,
@@ -78,8 +77,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count,
 		return -EFBIG;
 
 	while (count) {
-		size_t n = min_t(size_t, count,
-				 PAGE_SIZE - offset_in_page(pos));
+		size_t n = min_t(size_t, count, rest_of_page(pos));
 		struct folio *folio;
 		void *fsdata = NULL;
 		int res;
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index a30c8b57d478..84cd3e277366 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1157,8 +1157,8 @@ static int fuse_copy_folio(struct fuse_copy_state *cs, struct folio **foliop,
 			unsigned int copy = count;
 			unsigned int bytes_copied;
 
-			if (folio_test_highmem(folio) && count > PAGE_SIZE - offset_in_page(offset))
-				copy = PAGE_SIZE - offset_in_page(offset);
+			if (folio_test_highmem(folio) && count > rest_of_page(offset))
+				copy = rest_of_page(offset);
 
 			bytes_copied = fuse_copy_do(cs, &buf, &copy);
 			kunmap_local(mapaddr);
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 1fe19b4ee2f4..b5aa0676141f 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -852,7 +852,7 @@ static struct folio *__iomap_get_folio(struct iomap_iter *iter,
 	loff_t pos = iter->pos;
 
 	if (!mapping_large_folio_support(iter->inode->i_mapping))
-		len = min_t(size_t, len, PAGE_SIZE - offset_in_page(pos));
+		len = min_t(size_t, len, rest_of_page(pos));
 
 	if (iter->iomap.flags & IOMAP_F_FOLIO_BATCH) {
 		struct folio *folio = folio_batch_next(iter->fbatch);
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 6e69ce43a13f..a5b761304067 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -60,7 +60,7 @@ static struct page *nfs_page_iter_page_get(struct nfs_page_iter_page *i)
 
 	if (i->count != req->wb_bytes) {
 		size_t base = i->count + req->wb_pgbase;
-		size_t len = PAGE_SIZE - offset_in_page(base);
+		size_t len = rest_of_page(base);
 
 		page = nfs_page_to_page(req, base);
 		nfs_page_iter_page_advance(i, len);
diff --git a/fs/remap_range.c b/fs/remap_range.c
index 26afbbbfb10c..83f325e7f96b 100644
--- a/fs/remap_range.c
+++ b/fs/remap_range.c
@@ -199,8 +199,7 @@ static int vfs_dedupe_file_range_compare(struct file *src, loff_t srcoff,
 	while (len) {
 		struct folio *src_folio, *dst_folio;
 		void *src_addr, *dst_addr;
-		loff_t cmp_len = min(PAGE_SIZE - offset_in_page(srcoff),
-				     PAGE_SIZE - offset_in_page(dstoff));
+		loff_t cmp_len = min(rest_of_page(srcoff), rest_of_page(dstoff));
 
 		cmp_len = min(cmp_len, len);
 		if (cmp_len <= 0)
diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c
index 2998c9b62f4b..e07b153965ae 100644
--- a/fs/xfs/scrub/xfile.c
+++ b/fs/xfs/scrub/xfile.c
@@ -134,8 +134,7 @@ xfile_load(
 			 * No data stored at this offset, just zero the output
 			 * buffer until the next page boundary.
 			 */
-			len = min_t(ssize_t, count,
-				PAGE_SIZE - offset_in_page(pos));
+			len = min_t(ssize_t, count, rest_of_page(pos));
 			memset(buf, 0, len);
 		} else {
 			if (filemap_check_wb_err(inode->i_mapping, 0)) {
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h
index 624fab589c2c..c671d5383c12 100644
--- a/include/crypto/scatterwalk.h
+++ b/include/crypto/scatterwalk.h
@@ -73,7 +73,7 @@ static inline unsigned int scatterwalk_clamp(struct scatter_walk *walk,
 	 * page due to the data not being aligned to the algorithm's alignmask.
 	 */
 	if (IS_ENABLED(CONFIG_HIGHMEM))
-		limit = PAGE_SIZE - offset_in_page(walk->offset);
+		limit = rest_of_page(walk->offset);
 	else
 		limit = PAGE_SIZE;
 
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index af03db851a1d..05528ba886fb 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -507,12 +507,10 @@ static inline void memcpy_folio(struct folio *dst_folio, size_t dst_off,
 		const char *src = kmap_local_folio(src_folio, src_off);
 		size_t chunk = len;
 
-		if (folio_test_highmem(dst_folio) &&
-		    chunk > PAGE_SIZE - offset_in_page(dst_off))
-			chunk = PAGE_SIZE - offset_in_page(dst_off);
-		if (folio_test_highmem(src_folio) &&
-		    chunk > PAGE_SIZE - offset_in_page(src_off))
-			chunk = PAGE_SIZE - offset_in_page(src_off);
+		if (folio_test_highmem(dst_folio) && chunk > rest_of_page(dst_off))
+			chunk = rest_of_page(dst_off);
+		if (folio_test_highmem(src_folio) && chunk > rest_of_page(src_off))
+			chunk = rest_of_page(src_off);
 		memcpy(dst, src, chunk);
 		kunmap_local(src);
 		kunmap_local(dst);
@@ -580,9 +578,8 @@ static inline void memcpy_from_folio(char *to, struct folio *folio,
 		const char *from = kmap_local_folio(folio, offset);
 		size_t chunk = len;
 
-		if (folio_test_partial_kmap(folio) &&
-		    chunk > PAGE_SIZE - offset_in_page(offset))
-			chunk = PAGE_SIZE - offset_in_page(offset);
+		if (folio_test_partial_kmap(folio) && chunk > rest_of_page(offset))
+			chunk = rest_of_page(offset);
 		memcpy(to, from, chunk);
 		kunmap_local(from);
 
@@ -608,9 +605,8 @@ static inline void memcpy_to_folio(struct folio *folio, size_t offset,
 		char *to = kmap_local_folio(folio, offset);
 		size_t chunk = len;
 
-		if (folio_test_partial_kmap(folio) &&
-		    chunk > PAGE_SIZE - offset_in_page(offset))
-			chunk = PAGE_SIZE - offset_in_page(offset);
+		if (folio_test_partial_kmap(folio) && chunk > rest_of_page(offset))
+			chunk = rest_of_page(offset);
 		memcpy(to, from, chunk);
 		kunmap_local(to);
 
@@ -642,7 +638,7 @@ static inline __must_check void *folio_zero_tail(struct folio *folio,
 	size_t len = folio_size(folio) - offset;
 
 	if (folio_test_partial_kmap(folio)) {
-		size_t max = PAGE_SIZE - offset_in_page(offset);
+		size_t max = rest_of_page(offset);
 
 		while (len > max) {
 			memset(kaddr, 0, max);
@@ -680,7 +676,7 @@ static inline void folio_fill_tail(struct folio *folio, size_t offset,
 	VM_BUG_ON(offset + len > folio_size(folio));
 
 	if (folio_test_partial_kmap(folio)) {
-		size_t max = PAGE_SIZE - offset_in_page(offset);
+		size_t max = rest_of_page(offset);
 
 		while (len > max) {
 			memcpy(to, from, max);
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 99b7209dabd7..6ae549192adb 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -142,7 +142,7 @@ static inline void *iomap_inline_data(const struct iomap *iomap, loff_t pos)
  */
 static inline bool iomap_inline_data_valid(const struct iomap *iomap)
 {
-	return iomap->length <= PAGE_SIZE - offset_in_page(iomap->inline_data);
+	return iomap->length <= rest_of_page(iomap->inline_data);
 }
 
 /*
diff --git a/include/linux/iov_iter.h b/include/linux/iov_iter.h
index f9a17fbbd398..13a9ee653ef8 100644
--- a/include/linux/iov_iter.h
+++ b/include/linux/iov_iter.h
@@ -227,8 +227,7 @@ size_t iterate_xarray(struct iov_iter *iter, size_t len, void *priv, void *priv2
 		while (flen) {
 			void *base = kmap_local_folio(folio, offset);
 
-			part = min_t(size_t, flen,
-				     PAGE_SIZE - offset_in_page(offset));
+			part = min_t(size_t, flen, rest_of_page(offset));
 			remain = step(base, progress, part, priv, priv2);
 			kunmap_local(base);
 
diff --git a/include/linux/mm.h b/include/linux/mm.h
index dc1ad71a2a70..13e93be30501 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2579,6 +2579,8 @@ extern void pagefault_out_of_memory(void);
 #define offset_in_page(p)	((unsigned long)(p) & ~PAGE_MASK)
 #define offset_in_folio(folio, p) ((unsigned long)(p) & (folio_size(folio) - 1))
 
+#define rest_of_page(p)		(PAGE_SIZE - offset_in_page(p))
+
 /*
  * Parameter block passed down to zap_pte_range in exceptional cases.
  */
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 3e7de2661417..1db2868b90c9 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -590,7 +590,7 @@ long perf_output_copy_aux(struct perf_output_handle *aux_handle,
 	to &= (rb->aux_nr_pages << PAGE_SHIFT) - 1;
 
 	do {
-		tocopy = PAGE_SIZE - offset_in_page(from);
+		tocopy = rest_of_page(from);
 		if (to > from)
 			tocopy = min(tocopy, to - from);
 		if (!tocopy)
diff --git a/lib/bitmap-str.c b/lib/bitmap-str.c
index be745209507a..a357342d5d6c 100644
--- a/lib/bitmap-str.c
+++ b/lib/bitmap-str.c
@@ -58,7 +58,7 @@ EXPORT_SYMBOL(bitmap_parse_user);
 int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
 			    int nmaskbits)
 {
-	ptrdiff_t len = PAGE_SIZE - offset_in_page(buf);
+	ptrdiff_t len = rest_of_page(buf);
 
 	return list ? scnprintf(buf, len, "%*pbl\n", nmaskbits, maskp) :
 		      scnprintf(buf, len, "%*pb\n", nmaskbits, maskp);
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 545250507f08..4258cf910fec 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -483,9 +483,8 @@ size_t copy_folio_from_iter_atomic(struct folio *folio, size_t offset,
 		char *to = kmap_local_folio(folio, offset);
 
 		n = bytes - copied;
-		if (folio_test_partial_kmap(folio) &&
-		    n > PAGE_SIZE - offset_in_page(offset))
-			n = PAGE_SIZE - offset_in_page(offset);
+		if (folio_test_partial_kmap(folio) && n > rest_of_page(offset))
+			n = rest_of_page(offset);
 
 		pagefault_disable();
 		n = __copy_from_iter(to, n, i);
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index 370f4f37dcec..3aded4ba4575 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -87,12 +87,6 @@ struct virtio_chan {
 
 static struct list_head virtio_chan_list;
 
-/* How many bytes left in this page. */
-static unsigned int rest_of_page(void *data)
-{
-	return PAGE_SIZE - offset_in_page(data);
-}
-
 /**
  * p9_virtio_close - reclaim resources of a channel
  * @client: client instance
diff --git a/sound/virtio/virtio_pcm_msg.c b/sound/virtio/virtio_pcm_msg.c
index 9778020a7ba8..2f45664a21ac 100644
--- a/sound/virtio/virtio_pcm_msg.c
+++ b/sound/virtio/virtio_pcm_msg.c
@@ -56,7 +56,7 @@ static int virtsnd_pcm_sg_num(u8 *data, unsigned int length)
 		phys_addr_t pg_address = page_to_phys(pg);
 		size_t pg_length;
 
-		pg_length = PAGE_SIZE - offset_in_page(data);
+		pg_length = rest_of_page(data);
 		if (pg_length > length)
 			pg_length = length;
 
@@ -96,7 +96,7 @@ static void virtsnd_pcm_sg_from(struct scatterlist *sgs, int nsgs, u8 *data,
 		struct page *pg = vmalloc_to_page(data);
 		size_t pg_length;
 
-		pg_length = PAGE_SIZE - offset_in_page(data);
+		pg_length = rest_of_page(data);
 		if (pg_length > length)
 			pg_length = length;
 
-- 
2.43.0


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

* [PATCH 08/12] coresight: don't use bitmap_print_to_pagebuf()
  2026-02-19 18:13 [PATCH 00/12] cleanup bitmaps printing in sysfs Yury Norov
                   ` (6 preceding siblings ...)
  2026-02-19 18:13 ` [PATCH 07/12] mm: add rest_of_page() macro Yury Norov
@ 2026-02-19 18:14 ` Yury Norov
  2026-02-19 18:42   ` Thomas Weißschuh
  2026-02-19 18:14 ` [PATCH 09/12] fpga: m10bmc-sec: switch show_canceled_csk() to using scnprintf() Yury Norov
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Yury Norov @ 2026-02-19 18:14 UTC (permalink / raw)
  To: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev
  Cc: Yury Norov

Switch to a more common scnprintf("%*pbl") where appropriate.

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 .../hwtracing/coresight/coresight-cti-sysfs.c | 33 +++++++++----------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
index 572b80ee96fb..182c8db52a04 100644
--- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
+++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
@@ -606,14 +606,11 @@ static ssize_t chan_gate_enable_show(struct device *dev,
 	struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
 	struct cti_config *cfg = &drvdata->config;
 	unsigned long ctigate_bitmask = cfg->ctigate;
-	int size = 0;
 
 	if (cfg->ctigate == 0)
-		size = sprintf(buf, "\n");
-	else
-		size = bitmap_print_to_pagebuf(true, buf, &ctigate_bitmask,
-					       cfg->nr_ctm_channels);
-	return size;
+		return sprintf(buf, "\n");
+
+	return scnprintf(buf, rest_of_page(buf), "%*pbl\n", cfg->nr_ctm_channels, &ctigate_bitmask);
 }
 static DEVICE_ATTR_RW(chan_gate_enable);
 
@@ -710,12 +707,13 @@ static ssize_t trigout_filtered_show(struct device *dev,
 {
 	struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
 	struct cti_config *cfg = &drvdata->config;
-	int size = 0, nr_trig_max = cfg->nr_trig_max;
+	int nr_trig_max = cfg->nr_trig_max;
 	unsigned long mask = cfg->trig_out_filter;
 
-	if (mask)
-		size = bitmap_print_to_pagebuf(true, buf, &mask, nr_trig_max);
-	return size;
+	if (mask == 0)
+		return 0;
+
+	return scnprintf(buf, rest_of_page(buf), "%*pbl\n", nr_trig_max, &mask);
 }
 static DEVICE_ATTR_RO(trigout_filtered);
 
@@ -834,7 +832,7 @@ static ssize_t print_chan_list(struct device *dev,
 {
 	struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
 	struct cti_config *config = &drvdata->config;
-	int size, i;
+	int i;
 	unsigned long inuse_bits = 0, chan_mask;
 
 	/* scan regs to get bitmap of channels in use. */
@@ -852,11 +850,10 @@ static ssize_t print_chan_list(struct device *dev,
 	/* list of channels, or 'none' */
 	chan_mask = GENMASK(config->nr_ctm_channels - 1, 0);
 	if (inuse_bits & chan_mask)
-		size = bitmap_print_to_pagebuf(true, buf, &inuse_bits,
-					       config->nr_ctm_channels);
-	else
-		size = sprintf(buf, "\n");
-	return size;
+		return scnprintf(buf, rest_of_page(buf), "%*pbl\n",
+				 config->nr_ctm_channels, &inuse_bits);
+
+	return sprintf(buf, "\n");
 }
 
 static ssize_t chan_inuse_show(struct device *dev,
@@ -928,7 +925,7 @@ static ssize_t trigin_sig_show(struct device *dev,
 	struct cti_config *cfg = &drvdata->config;
 	unsigned long mask = con->con_in->used_mask;
 
-	return bitmap_print_to_pagebuf(true, buf, &mask, cfg->nr_trig_max);
+	return scnprintf(buf, rest_of_page(buf), "%*pbl\n", cfg->nr_trig_max, &mask);
 }
 
 static ssize_t trigout_sig_show(struct device *dev,
@@ -942,7 +939,7 @@ static ssize_t trigout_sig_show(struct device *dev,
 	struct cti_config *cfg = &drvdata->config;
 	unsigned long mask = con->con_out->used_mask;
 
-	return bitmap_print_to_pagebuf(true, buf, &mask, cfg->nr_trig_max);
+	return scnprintf(buf, rest_of_page(buf), "%*pbl\n", cfg->nr_trig_max, &mask);
 }
 
 /* convert a sig type id to a name */
-- 
2.43.0


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

* [PATCH 09/12] fpga: m10bmc-sec: switch show_canceled_csk() to using scnprintf()
  2026-02-19 18:13 [PATCH 00/12] cleanup bitmaps printing in sysfs Yury Norov
                   ` (7 preceding siblings ...)
  2026-02-19 18:14 ` [PATCH 08/12] coresight: don't use bitmap_print_to_pagebuf() Yury Norov
@ 2026-02-19 18:14 ` Yury Norov
  2026-02-19 23:43   ` Russ Weight
  2026-02-26  7:39   ` Xu Yilun
  2026-02-19 18:14 ` [PATCH 10/12] net-sysfs: switch xps_queue_show() " Yury Norov
                   ` (3 subsequent siblings)
  12 siblings, 2 replies; 19+ messages in thread
From: Yury Norov @ 2026-02-19 18:14 UTC (permalink / raw)
  To: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev
  Cc: Yury Norov

Switch show_canceled_csk() to use a more common scnprintf("%*pbl").

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 drivers/fpga/intel-m10-bmc-sec-update.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/fpga/intel-m10-bmc-sec-update.c b/drivers/fpga/intel-m10-bmc-sec-update.c
index 10f678b9ed36..5ae76b8ece18 100644
--- a/drivers/fpga/intel-m10-bmc-sec-update.c
+++ b/drivers/fpga/intel-m10-bmc-sec-update.c
@@ -10,6 +10,7 @@
 #include <linux/firmware.h>
 #include <linux/mfd/intel-m10-bmc.h>
 #include <linux/mod_devicetable.h>
+#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
@@ -183,7 +184,7 @@ show_canceled_csk(struct device *dev, u32 addr, char *buf)
 
 	bitmap_from_arr32(csk_map, csk32, CSK_BIT_LEN);
 	bitmap_complement(csk_map, csk_map, CSK_BIT_LEN);
-	return bitmap_print_to_pagebuf(1, buf, csk_map, CSK_BIT_LEN);
+	return scnprintf(buf, rest_of_page(buf), "%*pbl\n", CSK_BIT_LEN, csk_map);
 }
 
 #define DEVICE_ATTR_SEC_CSK_RO(_name)						\
-- 
2.43.0


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

* [PATCH 10/12] net-sysfs: switch xps_queue_show() to using scnprintf()
  2026-02-19 18:13 [PATCH 00/12] cleanup bitmaps printing in sysfs Yury Norov
                   ` (8 preceding siblings ...)
  2026-02-19 18:14 ` [PATCH 09/12] fpga: m10bmc-sec: switch show_canceled_csk() to using scnprintf() Yury Norov
@ 2026-02-19 18:14 ` Yury Norov
  2026-02-19 18:14 ` [PATCH 11/12] cpumask: switch cpumap_print_to_pagebuf() " Yury Norov
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Yury Norov @ 2026-02-19 18:14 UTC (permalink / raw)
  To: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev
  Cc: Yury Norov

Switch the function to use a more common scnprintf("%pb").

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 net/core/net-sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 07624b682b08..501c75ecda1c 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1754,7 +1754,7 @@ static ssize_t xps_queue_show(struct net_device *dev, unsigned int index,
 out_no_maps:
 	rcu_read_unlock();
 
-	len = bitmap_print_to_pagebuf(false, buf, mask, nr_ids);
+	len = scnprintf(buf, rest_of_page(buf), "%*pb\n", nr_ids, mask);
 	bitmap_free(mask);
 
 	return len < PAGE_SIZE ? len : -EINVAL;
-- 
2.43.0


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

* [PATCH 11/12] cpumask: switch cpumap_print_to_pagebuf() to using scnprintf()
  2026-02-19 18:13 [PATCH 00/12] cleanup bitmaps printing in sysfs Yury Norov
                   ` (9 preceding siblings ...)
  2026-02-19 18:14 ` [PATCH 10/12] net-sysfs: switch xps_queue_show() " Yury Norov
@ 2026-02-19 18:14 ` Yury Norov
  2026-02-19 18:14 ` [PATCH 12/12] bitmap: drop bitmap_print_to_pagebuf() Yury Norov
  2026-02-19 19:41 ` [PATCH 00/12] cleanup bitmaps printing in sysfs Jakub Kicinski
  12 siblings, 0 replies; 19+ messages in thread
From: Yury Norov @ 2026-02-19 18:14 UTC (permalink / raw)
  To: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev
  Cc: Yury Norov

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 | 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


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

* [PATCH 12/12] bitmap: drop bitmap_print_to_pagebuf()
  2026-02-19 18:13 [PATCH 00/12] cleanup bitmaps printing in sysfs Yury Norov
                   ` (10 preceding siblings ...)
  2026-02-19 18:14 ` [PATCH 11/12] cpumask: switch cpumap_print_to_pagebuf() " Yury Norov
@ 2026-02-19 18:14 ` Yury Norov
  2026-02-19 19:41 ` [PATCH 00/12] cleanup bitmaps printing in sysfs Jakub Kicinski
  12 siblings, 0 replies; 19+ messages in thread
From: Yury Norov @ 2026-02-19 18:14 UTC (permalink / raw)
  To: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev
  Cc: Yury Norov

Now that all users of the function 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 a357342d5d6c..49f4118c5cd3 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 = rest_of_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("%*pbl") 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, rest_of_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.43.0


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

* Re: [PATCH 08/12] coresight: don't use bitmap_print_to_pagebuf()
  2026-02-19 18:14 ` [PATCH 08/12] coresight: don't use bitmap_print_to_pagebuf() Yury Norov
@ 2026-02-19 18:42   ` Thomas Weißschuh
  0 siblings, 0 replies; 19+ messages in thread
From: Thomas Weißschuh @ 2026-02-19 18:42 UTC (permalink / raw)
  To: Yury Norov
  Cc: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev

Hi Yury,

On 2026-02-19 13:14:00-0500, Yury Norov wrote:
> Switch to a more common scnprintf("%*pbl") where appropriate.
> 
> Signed-off-by: Yury Norov <ynorov@nvidia.com>
> ---
>  .../hwtracing/coresight/coresight-cti-sysfs.c | 33 +++++++++----------
>  1 file changed, 15 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> index 572b80ee96fb..182c8db52a04 100644
> --- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> @@ -606,14 +606,11 @@ static ssize_t chan_gate_enable_show(struct device *dev,
>  	struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
>  	struct cti_config *cfg = &drvdata->config;
>  	unsigned long ctigate_bitmask = cfg->ctigate;
> -	int size = 0;
>  
>  	if (cfg->ctigate == 0)
> -		size = sprintf(buf, "\n");
> -	else
> -		size = bitmap_print_to_pagebuf(true, buf, &ctigate_bitmask,
> -					       cfg->nr_ctm_channels);
> -	return size;
> +		return sprintf(buf, "\n");
> +
> +	return scnprintf(buf, rest_of_page(buf), "%*pbl\n", cfg->nr_ctm_channels, &ctigate_bitmask);

For sysfs show handlers the correct formatting function is sysfs_emit()
rather than raw scnprintf(). It validates that buf is page-aligned
(which is always true for sysfs show handlers) and that the output does
not exceed PAGE_SIZE.

(...)


Thomas

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

* Re: [PATCH 00/12] cleanup bitmaps printing in sysfs
  2026-02-19 18:13 [PATCH 00/12] cleanup bitmaps printing in sysfs Yury Norov
                   ` (11 preceding siblings ...)
  2026-02-19 18:14 ` [PATCH 12/12] bitmap: drop bitmap_print_to_pagebuf() Yury Norov
@ 2026-02-19 19:41 ` Jakub Kicinski
  2026-03-03 18:17   ` Yury Norov
  12 siblings, 1 reply; 19+ messages in thread
From: Jakub Kicinski @ 2026-02-19 19:41 UTC (permalink / raw)
  To: Yury Norov
  Cc: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	James Clark, Jerin Jacob, Linu Cherian, Lukasz Luba,
	Madhavan Srinivasan, Michael Ellerman, Mike Leach, Moritz Fischer,
	Nicholas Piggin, Paolo Abeni, Rasmus Villemoes, Simon Horman,
	Stanislav Fomichev, Subbaraya Sundeep, Sunil Goutham,
	Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng, Yury Norov,
	Zhang Rui, hariprasad, coresight, linux-arm-kernel, linux-fpga,
	linux-pm, linuxppc-dev, netdev

On Thu, 19 Feb 2026 13:13:52 -0500 Yury Norov wrote:
>  .../marvell/octeontx2/af/rvu_debugfs.c        | 28 +++----------
>  drivers/net/ethernet/meta/fbnic/fbnic_tlv.c   |  6 +--
>  drivers/s390/net/qeth_core_main.c             |  6 +--
>  net/core/net-sysfs.c                          |  2 +-

Please split these changes out and submit them to the correct subsystem
after the merge window. Then push patch 12 during the next merge window.

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

* Re: [PATCH 09/12] fpga: m10bmc-sec: switch show_canceled_csk() to using scnprintf()
  2026-02-19 18:14 ` [PATCH 09/12] fpga: m10bmc-sec: switch show_canceled_csk() to using scnprintf() Yury Norov
@ 2026-02-19 23:43   ` Russ Weight
  2026-02-26  7:39   ` Xu Yilun
  1 sibling, 0 replies; 19+ messages in thread
From: Russ Weight @ 2026-02-19 23:43 UTC (permalink / raw)
  To: Yury Norov
  Cc: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev

On Thu, Feb 19, 2026 at 01:14:01PM -0500, Yury Norov wrote:
> Switch show_canceled_csk() to use a more common scnprintf("%*pbl").
> 
> Signed-off-by: Yury Norov <ynorov@nvidia.com>

Reviewed-by: Russ Weight <russ.weight@linux.dev>

> ---
>  drivers/fpga/intel-m10-bmc-sec-update.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/fpga/intel-m10-bmc-sec-update.c b/drivers/fpga/intel-m10-bmc-sec-update.c
> index 10f678b9ed36..5ae76b8ece18 100644
> --- a/drivers/fpga/intel-m10-bmc-sec-update.c
> +++ b/drivers/fpga/intel-m10-bmc-sec-update.c
> @@ -10,6 +10,7 @@
>  #include <linux/firmware.h>
>  #include <linux/mfd/intel-m10-bmc.h>
>  #include <linux/mod_devicetable.h>
> +#include <linux/mm.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
> @@ -183,7 +184,7 @@ show_canceled_csk(struct device *dev, u32 addr, char *buf)
>  
>  	bitmap_from_arr32(csk_map, csk32, CSK_BIT_LEN);
>  	bitmap_complement(csk_map, csk_map, CSK_BIT_LEN);
> -	return bitmap_print_to_pagebuf(1, buf, csk_map, CSK_BIT_LEN);
> +	return scnprintf(buf, rest_of_page(buf), "%*pbl\n", CSK_BIT_LEN, csk_map);
>  }
>  
>  #define DEVICE_ATTR_SEC_CSK_RO(_name)						\
> -- 
> 2.43.0
> 

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

* Re: [PATCH 01/12] powerpc/xive: simplify xive_spapr_debug_show()
  2026-02-19 18:13 ` [PATCH 01/12] powerpc/xive: simplify xive_spapr_debug_show() Yury Norov
@ 2026-02-23 13:13   ` Shrikanth Hegde
  0 siblings, 0 replies; 19+ messages in thread
From: Shrikanth Hegde @ 2026-02-23 13:13 UTC (permalink / raw)
  To: Yury Norov, linuxppc-dev
  Cc: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, netdev



On 2/19/26 11:43 PM, Yury Norov wrote:
> The function creates temporary buffer to convert xibm->bitmap to a
> human-readable list before passing it to seq_printf. Drop it and print
> the list in seq_printf() directly with the "%*pbl" specifier.
> 
> Signed-off-by: Yury Norov <ynorov@nvidia.com>
> ---
>   arch/powerpc/sysdev/xive/spapr.c | 12 ++----------
>   1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/powerpc/sysdev/xive/spapr.c b/arch/powerpc/sysdev/xive/spapr.c
> index 5aedbe3e8e6a..f818299579b1 100644
> --- a/arch/powerpc/sysdev/xive/spapr.c
> +++ b/arch/powerpc/sysdev/xive/spapr.c
> @@ -667,17 +667,9 @@ static void xive_spapr_sync_source(u32 hw_irq)
>   static int xive_spapr_debug_show(struct seq_file *m, void *private)
>   {
>   	struct xive_irq_bitmap *xibm;
> -	char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
>   
> -	if (!buf)
> -		return -ENOMEM;
> -
> -	list_for_each_entry(xibm, &xive_irq_bitmaps, list) {
> -		memset(buf, 0, PAGE_SIZE);
> -		bitmap_print_to_pagebuf(true, buf, xibm->bitmap, xibm->count);
> -		seq_printf(m, "bitmap #%d: %s", xibm->count, buf);
> -	}
> -	kfree(buf);
> +	list_for_each_entry(xibm, &xive_irq_bitmaps, list)
> +		seq_printf(m, "bitmap #%d: %*pbl\n", xibm->count, xibm->count, xibm->bitmap);
>   
>   	return 0;
>   }

Looks good to me.

Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>


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

* Re: [PATCH 09/12] fpga: m10bmc-sec: switch show_canceled_csk() to using scnprintf()
  2026-02-19 18:14 ` [PATCH 09/12] fpga: m10bmc-sec: switch show_canceled_csk() to using scnprintf() Yury Norov
  2026-02-19 23:43   ` Russ Weight
@ 2026-02-26  7:39   ` Xu Yilun
  1 sibling, 0 replies; 19+ messages in thread
From: Xu Yilun @ 2026-02-26  7:39 UTC (permalink / raw)
  To: Yury Norov
  Cc: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	Jakub Kicinski, James Clark, Jerin Jacob, Linu Cherian,
	Lukasz Luba, Madhavan Srinivasan, Michael Ellerman, Mike Leach,
	Moritz Fischer, Nicholas Piggin, Paolo Abeni, Rasmus Villemoes,
	Simon Horman, Stanislav Fomichev, Subbaraya Sundeep,
	Sunil Goutham, Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng,
	Yury Norov, Zhang Rui, hariprasad, coresight, linux-arm-kernel,
	linux-fpga, linux-pm, linuxppc-dev, netdev

On Thu, Feb 19, 2026 at 01:14:01PM -0500, Yury Norov wrote:
> Switch show_canceled_csk() to use a more common scnprintf("%*pbl").
> 
> Signed-off-by: Yury Norov <ynorov@nvidia.com>
> ---
>  drivers/fpga/intel-m10-bmc-sec-update.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/fpga/intel-m10-bmc-sec-update.c b/drivers/fpga/intel-m10-bmc-sec-update.c
> index 10f678b9ed36..5ae76b8ece18 100644
> --- a/drivers/fpga/intel-m10-bmc-sec-update.c
> +++ b/drivers/fpga/intel-m10-bmc-sec-update.c
> @@ -10,6 +10,7 @@
>  #include <linux/firmware.h>
>  #include <linux/mfd/intel-m10-bmc.h>
>  #include <linux/mod_devicetable.h>
> +#include <linux/mm.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
> @@ -183,7 +184,7 @@ show_canceled_csk(struct device *dev, u32 addr, char *buf)
>  
>  	bitmap_from_arr32(csk_map, csk32, CSK_BIT_LEN);
>  	bitmap_complement(csk_map, csk_map, CSK_BIT_LEN);
> -	return bitmap_print_to_pagebuf(1, buf, csk_map, CSK_BIT_LEN);
> +	return scnprintf(buf, rest_of_page(buf), "%*pbl\n", CSK_BIT_LEN, csk_map);

As Thomas mentioned, use sysfs_emit()

>  }
>  
>  #define DEVICE_ATTR_SEC_CSK_RO(_name)						\
> -- 
> 2.43.0
> 
> 

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

* Re: [PATCH 00/12] cleanup bitmaps printing in sysfs
  2026-02-19 19:41 ` [PATCH 00/12] cleanup bitmaps printing in sysfs Jakub Kicinski
@ 2026-03-03 18:17   ` Yury Norov
  0 siblings, 0 replies; 19+ messages in thread
From: Yury Norov @ 2026-03-03 18:17 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: linux-kernel, Christophe Leroy (CS GROUP), David S. Miller,
	Peter Zijlstra (Intel), Rafael J. Wysocki, Alexander Shishkin,
	Andrew Lunn, Andrew Morton, Antoine Tenart, Christian Brauner,
	Daniel Lezcano, Eric Dumazet, Geetha sowjanya, Ingo Molnar,
	James Clark, Jerin Jacob, Linu Cherian, Lukasz Luba,
	Madhavan Srinivasan, Michael Ellerman, Mike Leach, Moritz Fischer,
	Nicholas Piggin, Paolo Abeni, Rasmus Villemoes, Simon Horman,
	Stanislav Fomichev, Subbaraya Sundeep, Sunil Goutham,
	Suzuki K Poulose, Tom Rix, Xu Yilun, Yajun Deng, Yury Norov,
	Zhang Rui, hariprasad, coresight, linux-arm-kernel, linux-fpga,
	linux-pm, linuxppc-dev, netdev

On Thu, Feb 19, 2026 at 11:41:20AM -0800, Jakub Kicinski wrote:
> On Thu, 19 Feb 2026 13:13:52 -0500 Yury Norov wrote:
> >  .../marvell/octeontx2/af/rvu_debugfs.c        | 28 +++----------
> >  drivers/net/ethernet/meta/fbnic/fbnic_tlv.c   |  6 +--
> >  drivers/s390/net/qeth_core_main.c             |  6 +--
> >  net/core/net-sysfs.c                          |  2 +-
> 
> Please split these changes out and submit them to the correct subsystem
> after the merge window. Then push patch 12 during the next merge window.

OK, I'll split them out, will switch to sysfs_emit() where appropriate
as suggested by Tomas. I'll move those tests cleanups by myself.

Will resend shortly.

Thanks,
Yury

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

end of thread, other threads:[~2026-03-03 18:17 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-19 18:13 [PATCH 00/12] cleanup bitmaps printing in sysfs Yury Norov
2026-02-19 18:13 ` [PATCH 01/12] powerpc/xive: simplify xive_spapr_debug_show() Yury Norov
2026-02-23 13:13   ` Shrikanth Hegde
2026-02-19 18:13 ` [PATCH 02/12] octeontx2-af: siplify rvu_debugfs Yury Norov
2026-02-19 18:13 ` [PATCH 03/12] thermal: intel: switch cpumask_get() to using cpumask_print_to_pagebuf() Yury Norov
2026-02-19 18:13 ` [PATCH 04/12] lib/prime_numbers: drop temporary buffer in dump_primes() Yury Norov
2026-02-19 18:13 ` [PATCH 05/12] bitmap: switch test to scnprintf("%*pbl") Yury Norov
2026-02-19 18:13 ` [PATCH 06/12] bitmap: align test_bitmap output Yury Norov
2026-02-19 18:13 ` [PATCH 07/12] mm: add rest_of_page() macro Yury Norov
2026-02-19 18:14 ` [PATCH 08/12] coresight: don't use bitmap_print_to_pagebuf() Yury Norov
2026-02-19 18:42   ` Thomas Weißschuh
2026-02-19 18:14 ` [PATCH 09/12] fpga: m10bmc-sec: switch show_canceled_csk() to using scnprintf() Yury Norov
2026-02-19 23:43   ` Russ Weight
2026-02-26  7:39   ` Xu Yilun
2026-02-19 18:14 ` [PATCH 10/12] net-sysfs: switch xps_queue_show() " Yury Norov
2026-02-19 18:14 ` [PATCH 11/12] cpumask: switch cpumap_print_to_pagebuf() " Yury Norov
2026-02-19 18:14 ` [PATCH 12/12] bitmap: drop bitmap_print_to_pagebuf() Yury Norov
2026-02-19 19:41 ` [PATCH 00/12] cleanup bitmaps printing in sysfs Jakub Kicinski
2026-03-03 18:17   ` Yury Norov

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