Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-cleanup-bitmaps-printing'

Yury Norov says:

====================
net: cleanup bitmaps printing

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
scnprintf() with no modification. This is useless because scnprintf(),
and helpers based on it like seq_pritf() and sysfs_emit(), take care of
not overflowing the buffer by itself, and perfectly print bitmaps with
"%*pb[l]".

v1: https://lore.kernel.org/all/20260219181407.290201-1-ynorov@nvidia.com/
====================

Link: https://patch.msgid.link/20260319201713.941956-1-ynorov@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

+6 -24
+5 -23
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
··· 962 962 963 963 static void print_npa_qsize(struct seq_file *m, struct rvu_pfvf *pfvf) 964 964 { 965 - char *buf; 966 - 967 - buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 968 - if (!buf) 969 - return; 970 - 971 965 if (!pfvf->aura_ctx) { 972 966 seq_puts(m, "Aura context is not initialized\n"); 973 967 } else { 974 - bitmap_print_to_pagebuf(false, buf, pfvf->aura_bmap, 975 - pfvf->aura_ctx->qsize); 976 968 seq_printf(m, "Aura count : %d\n", pfvf->aura_ctx->qsize); 977 - seq_printf(m, "Aura context ena/dis bitmap : %s\n", buf); 969 + seq_printf(m, "Aura context ena/dis bitmap : %*pb\n", 970 + pfvf->aura_ctx->qsize, pfvf->aura_bmap); 978 971 } 979 972 980 973 if (!pfvf->pool_ctx) { 981 974 seq_puts(m, "Pool context is not initialized\n"); 982 975 } else { 983 - bitmap_print_to_pagebuf(false, buf, pfvf->pool_bmap, 984 - pfvf->pool_ctx->qsize); 985 976 seq_printf(m, "Pool count : %d\n", pfvf->pool_ctx->qsize); 986 - seq_printf(m, "Pool context ena/dis bitmap : %s\n", buf); 977 + seq_printf(m, "Pool context ena/dis bitmap : %*pb\n", 978 + pfvf->pool_ctx->qsize, pfvf->pool_bmap); 987 979 } 988 - kfree(buf); 989 980 } 990 981 991 982 /* The 'qsize' entry dumps current Aura/Pool context Qsize ··· 2538 2547 static void print_nix_qctx_qsize(struct seq_file *filp, int qsize, 2539 2548 unsigned long *bmap, char *qtype) 2540 2549 { 2541 - char *buf; 2542 - 2543 - buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 2544 - if (!buf) 2545 - return; 2546 - 2547 - bitmap_print_to_pagebuf(false, buf, bmap, qsize); 2548 2550 seq_printf(filp, "%s context count : %d\n", qtype, qsize); 2549 - seq_printf(filp, "%s context ena/dis bitmap : %s\n", 2550 - qtype, buf); 2551 - kfree(buf); 2551 + seq_printf(filp, "%s context ena/dis bitmap : %*pb\n", qtype, qsize, bmap); 2552 2552 } 2553 2553 2554 2554 static void print_nix_qsize(struct seq_file *filp, struct rvu_pfvf *pfvf)
+1 -1
net/core/net-sysfs.c
··· 1739 1739 out_no_maps: 1740 1740 rcu_read_unlock(); 1741 1741 1742 - len = bitmap_print_to_pagebuf(false, buf, mask, nr_ids); 1742 + len = sysfs_emit(buf, "%*pb\n", nr_ids, mask); 1743 1743 bitmap_free(mask); 1744 1744 1745 1745 return len < PAGE_SIZE ? len : -EINVAL;