cleanup bitmaps printing in sysfs
Subsystems (39)
cover cleanup bitmaps printing in sysfs
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(-)
Signature · 1 line
2.43.0
PATCH 1/12 powerpc/xive: simplify xive_spapr_debug_show()
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.
--- arch/powerpc/sysdev/xive/spapr.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
arch/powerpc/sysdev/xive/spapr.c +2 -10
@@ -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 ; }
Signature · 1 line
2.43.0
Re: [PATCH 01/12] powerpc/xive: simplify xive_spapr_debug_show()
Quoted 23 lines · Yury Norov
The function creates temporary buffer to convert
xibm->bitmapto a human-readable list before passing it toseq_printf. Drop it and print the list inseq_printf()directly with the "%*pbl" specifier.Signed-off-by Yury Norov <[email protected]>--- arch/powerpc/sysdev/xive/spapr.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)arch/powerpc/sysdev/xive/spapr.c +0
-5@@ -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) {
arch/powerpc/sysdev/xive/spapr.c static void xive_spapr_sync_source(u32 hw_irq) · line 675
Quoted 10 lines
arch/powerpc/sysdev/xive/spapr.c +2
-5-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.
PATCH 2/12 octeontx2-af: siplify rvu_debugfs
In reply to Yury NorovThe 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.
--- .../marvell/octeontx2/af/rvu_debugfs.c | 28 ++++--------------- 1 file changed, 5 insertions(+), 23 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +5 -23
@@ -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)
Signature · 1 line
2.43.0
PATCH 3/12 thermal: intel: switch cpumask_get() to using cpumask_print_to_pagebuf()
In reply to Yury NorovThe function opencodes cpumask_print_to_pagebuf() with more generic bitmap_print_to_pagebuf(). Switch to using the proper API.
--- drivers/thermal/intel/intel_powerclamp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/thermal/intel/intel_powerclamp.c +1 -2
@@ -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 = {
Signature · 1 line
2.43.0
PATCH 4/12 lib/prime_numbers: drop temporary buffer in dump_primes()
In reply to Yury NorovThe function uses temporary buffer to convert primes bitmap into human readable format. Switch to using kunit_info("%*pbl")", and drop the buffer.
--- lib/math/tests/prime_numbers_kunit.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/math/tests/prime_numbers_kunit.c +2 -4
@@ -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)
Signature · 1 line
2.43.0
PATCH 5/12 bitmap: switch test to scnprintf("%*pbl")
In reply to Yury Norovscnprintf("%*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.
---
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(-)
lib/test_bitmap.c +5 -5
@@ -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);
Signature · 1 line
2.43.0
PATCH 6/12 bitmap: align test_bitmap output
In reply to Yury NorovDifferent 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--- lib/test_bitmap.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
lib/test_bitmap.c +6 -7
@@ -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
Signature · 1 line
2.43.0
PATCH 7/12 mm: add rest_of_page() macro
In reply to Yury NorovThe 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.
--- 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(-)
arch/arm64/kernel/patching.c +1 -3
@@ -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 );
arch/powerpc/lib/code-patching.c +3 -3
@@ -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 ())
arch/riscv/kernel/sbi.c +2 -2
@@ -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,
arch/s390/kvm/gaccess.c +3 -3
@@ -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;
arch/x86/kvm/emulate.c +2 -2
@@ -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 ;
drivers/block/null_blk/main.c +2 -4
@@ -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,
drivers/gpu/drm/i915/gt/shmem_utils.c +2 -3
@@ -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;
drivers/md/dm-pcache/backing_dev.h +1 -1
@@ -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;
drivers/net/ethernet/meta/fbnic/fbnic_tlv.c +3 -3
@@ -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 };
drivers/s390/net/qeth_core_main.c +2 -4
@@ -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;
drivers/spi/spi-pl022.c +1 -2
@@ -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));
drivers/spi/spi.c +1 -3
@@ -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
fs/ext4/verity.c +1 -2
@@ -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;
fs/f2fs/verity.c +2 -4
@@ -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;
fs/fuse/dev.c +2 -2
@@ -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, ©);kunmap_local (mapaddr);
fs/iomap/buffered-io.c +1 -1
@@ -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);
fs/nfs/pagelist.c +1 -1
@@ -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);
fs/remap_range.c +1 -2
@@ -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 )
fs/xfs/scrub/xfile.c +1 -2
@@ -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 )) {
include/crypto/scatterwalk.h +1 -1
@@ -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 ;
include/linux/highmem.h +10 -14
@@ -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);
include/linux/iomap.h +1 -1
@@ -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); }/*
include/linux/iov_iter.h +1 -2
@@ -227,8 +227,7 @@ size_t iterate_xarray(struct iov_iter *iter, size_t len, void *priv, void *priv2while (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);
include/linux/mm.h +2 -0
@@ -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. */
kernel/events/ring_buffer.c +1 -1
@@ -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)
lib/bitmap-str.c +1 -1
@@ -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);
lib/iov_iter.c +2 -3
@@ -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);
net/9p/trans_virtio.c +0 -6
@@ -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
sound/virtio/virtio_pcm_msg.c +2 -2
@@ -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;
Signature · 1 line
2.43.0
PATCH 8/12 coresight: don't use bitmap_print_to_pagebuf()
In reply to Yury NorovSwitch to a more common scnprintf("%*pbl") where appropriate.
--- .../hwtracing/coresight/coresight-cti-sysfs.c | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-)
drivers/hwtracing/coresight/coresight-cti-sysfs.c +15 -18
@@ -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 */
Signature · 1 line
2.43.0
Re: [PATCH 08/12] coresight: don't use bitmap_print_to_pagebuf()
Hi Yury,
Quoted 16 lines · Yury Norov
Switch to a more common
scnprintf("%*pbl")where appropriate.Signed-off-by Yury Norov <[email protected]>--- .../hwtracing/coresight/coresight-cti-sysfs.c | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-)drivers/hwtracing/coresight/coresight-cti-sysfs.c +0
-1@@ -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 ;
drivers/hwtracing/coresight/coresight-cti-sysfs.c static ssize_t chan_gate_enable_show(struct device *dev, · line 613
Quoted 10 lines
drivers/hwtracing/coresight/coresight-cti-sysfs.c +3
-5if (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
PATCH 9/12 fpga: m10bmc-sec: switch show_canceled_csk() to using scnprintf()
In reply to Yury NorovSwitch show_canceled_csk() to use a more common scnprintf("%*pbl").
--- drivers/fpga/intel-m10-bmc-sec-update.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/fpga/intel-m10-bmc-sec-update.c +2 -1
@@ -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) \
Signature · 1 line
2.43.0
Re: [PATCH 09/12] fpga: m10bmc-sec: switch show_canceled_csk() to using scnprintf()
Quoted 3 lines · Yury Norov
Switch
show_canceled_csk()to use a more commonscnprintf("%*pbl").Signed-off-by Yury Norov <[email protected]>
Quoted 28 lines
--- drivers/fpga/intel-m10-bmc-sec-update.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/fpga/intel-m10-bmc-sec-update.c +2
-1@@ -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) \Signature · 1 line
2.43.0
Re: [PATCH 09/12] fpga: m10bmc-sec: switch show_canceled_csk() to using scnprintf()
In reply to Yury NorovQuoted 20 lines · Yury Norov
Switch
show_canceled_csk()to use a more commonscnprintf("%*pbl").Signed-off-by Yury Norov <[email protected]>--- drivers/fpga/intel-m10-bmc-sec-update.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/fpga/intel-m10-bmc-sec-update.c +1
-0@@ -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>
drivers/fpga/intel-m10-bmc-sec-update.c show_canceled_csk(struct device *dev, u32 addr, char *buf) · line 187
Quoted 5 lines
drivers/fpga/intel-m10-bmc-sec-update.c +1
-1@@ -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()
Quoted 7 lines
drivers/fpga/intel-m10-bmc-sec-update.c +0
-0}#define DEVICE_ATTR_SEC_CSK_RO (_name) \Signature · 1 line
2.43.0
PATCH 10/12 net-sysfs: switch xps_queue_show() to using scnprintf()
In reply to Yury NorovSwitch the function to use a more common scnprintf("%pb").
--- net/core/net-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/net-sysfs.c +1 -1
@@ -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 ;
Signature · 1 line
2.43.0
PATCH 11/12 cpumask: switch cpumap_print_to_pagebuf() to using scnprintf()
In reply to Yury NorovIn preparation for removing bitmap_print_to_pagebuf(), switch cpumap_print_to_pagebuf() to using scnprintf("%*pbl").
--- include/linux/cpumask.h | 17 +---------------- lib/cpumask.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 16 deletions(-)
include/linux/cpumask.h +1 -16
@@ -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
lib/cpumask.c +17 -0
@@ -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);
Signature · 1 line
2.43.0
PATCH 12/12 bitmap: drop bitmap_print_to_pagebuf()
In reply to Yury NorovNow that all users of the function are switched to the alternatives, drop the function.
--- include/linux/bitmap-str.h | 1 - lib/bitmap-str.c | 42 +++++--------------------------------- 2 files changed, 5 insertions(+), 38 deletions(-)
include/linux/bitmap-str.h +0 -1
@@ -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,
lib/bitmap-str.c +5 -37
76 lines not on this page · raw message
Signature · 1 line
2.43.0
Jakub Kicinski
maintainerQuoted 4 lines · 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.
Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · 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