* [PATCH RESEND 0/2] net: cleanup bitmaps printing @ 2026-03-03 18:55 Yury Norov 2026-03-03 18:55 ` [PATCH 1/2] octeontx2-af: siplify rvu_debugfs Yury Norov 2026-03-03 18:55 ` [PATCH 2/2] net-sysfs: switch xps_queue_show() to sysfs_emit() Yury Norov 0 siblings, 2 replies; 7+ messages in thread From: Yury Norov @ 2026-03-03 18:55 UTC (permalink / raw) To: Jakub Kicinski, Paolo Abeni, David S. Miller, Eric Dumazet, Andrew Lunn, Simon Horman, Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob, Subbaraya Sundeep, Stanislav Fomichev, Kuniyuki Iwashima, Christian Brauner, Yajun Deng, netdev, linux-kernel Cc: Yury Norov, Thomas Weißschuh, 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 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]". This is a resend of networking part of [1]. Patch #2 switches from plain scnprintf() to sysfs_emit, as pointed out by Thomas Weißschuh. [1] https://lore.kernel.org/all/20260219181407.290201-1-ynorov@nvidia.com/ Yury Norov (2): octeontx2-af: siplify rvu_debugfs net-sysfs: switch xps_queue_show() to sysfs_emit() .../marvell/octeontx2/af/rvu_debugfs.c | 28 ++++--------------- net/core/net-sysfs.c | 2 +- 2 files changed, 6 insertions(+), 24 deletions(-) -- 2.43.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] octeontx2-af: siplify rvu_debugfs 2026-03-03 18:55 [PATCH RESEND 0/2] net: cleanup bitmaps printing Yury Norov @ 2026-03-03 18:55 ` Yury Norov 2026-03-05 10:16 ` [1/2] " Simon Horman 2026-03-05 14:55 ` [PATCH 1/2] " Jakub Kicinski 2026-03-03 18:55 ` [PATCH 2/2] net-sysfs: switch xps_queue_show() to sysfs_emit() Yury Norov 1 sibling, 2 replies; 7+ messages in thread From: Yury Norov @ 2026-03-03 18:55 UTC (permalink / raw) To: Jakub Kicinski, Paolo Abeni, David S. Miller, Eric Dumazet, Andrew Lunn, Simon Horman, Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob, Subbaraya Sundeep, Stanislav Fomichev, Kuniyuki Iwashima, Christian Brauner, Yajun Deng, netdev, linux-kernel Cc: Yury Norov, Thomas Weißschuh, 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..159b910eef84 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] 7+ messages in thread
* Re: [1/2] octeontx2-af: siplify rvu_debugfs 2026-03-03 18:55 ` [PATCH 1/2] octeontx2-af: siplify rvu_debugfs Yury Norov @ 2026-03-05 10:16 ` Simon Horman 2026-03-05 14:55 ` [PATCH 1/2] " Jakub Kicinski 1 sibling, 0 replies; 7+ messages in thread From: Simon Horman @ 2026-03-05 10:16 UTC (permalink / raw) To: ynorov Cc: Simon Horman, edumazet, linux, andrew+netdev, pabeni, sbhatta, brauner, netdev, sdf, sgoutham, kuba, yajun.deng, kuniyu, yury.norov, jerinj, lcherian, gakula, linux-kernel, davem This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html --- octeontx2-af: siplify rvu_debugfs 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. > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c > index 413f9fa40b33..cae61c4de47f 100644 > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c > @@ -962,30 +962,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); ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ Does this code have a copy-paste error? The pool context output is displaying the aura bitmap instead of the pool bitmap. The old code correctly used pfvf->pool_bmap and pfvf->pool_ctx->qsize: bitmap_print_to_pagebuf(false, buf, pfvf->pool_bmap, pfvf->pool_ctx->qsize); But the new code uses pfvf->aura_bmap and pfvf->aura_ctx->qsize for both the aura and pool context displays. This makes the pool context debugfs output show incorrect information. > } > - kfree(buf); > } [ ... ] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] octeontx2-af: siplify rvu_debugfs 2026-03-03 18:55 ` [PATCH 1/2] octeontx2-af: siplify rvu_debugfs Yury Norov 2026-03-05 10:16 ` [1/2] " Simon Horman @ 2026-03-05 14:55 ` Jakub Kicinski 1 sibling, 0 replies; 7+ messages in thread From: Jakub Kicinski @ 2026-03-05 14:55 UTC (permalink / raw) To: Yury Norov Cc: Paolo Abeni, David S. Miller, Eric Dumazet, Andrew Lunn, Simon Horman, Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob, Subbaraya Sundeep, Stanislav Fomichev, Kuniyuki Iwashima, Christian Brauner, Yajun Deng, netdev, linux-kernel, Thomas Weißschuh, Yury Norov On Tue, 3 Mar 2026 13:55:05 -0500 Yury Norov wrote: > Subject: [PATCH 1/2] octeontx2-af: siplify rvu_debugfs when you respin - please also fix the typo in the subject ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] net-sysfs: switch xps_queue_show() to sysfs_emit() 2026-03-03 18:55 [PATCH RESEND 0/2] net: cleanup bitmaps printing Yury Norov 2026-03-03 18:55 ` [PATCH 1/2] octeontx2-af: siplify rvu_debugfs Yury Norov @ 2026-03-03 18:55 ` Yury Norov 2026-03-03 19:16 ` Thomas Weißschuh 1 sibling, 1 reply; 7+ messages in thread From: Yury Norov @ 2026-03-03 18:55 UTC (permalink / raw) To: Jakub Kicinski, Paolo Abeni, David S. Miller, Eric Dumazet, Andrew Lunn, Simon Horman, Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob, Subbaraya Sundeep, Stanislav Fomichev, Kuniyuki Iwashima, Christian Brauner, Yajun Deng, netdev, linux-kernel Cc: Yury Norov, Thomas Weißschuh, Yury Norov Switch the function to use the proper sysfs_emit("%pb"). Suggested-by: Thomas Weißschuh <linux@weissschuh.net> 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..a260f8b4d5c6 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 = sysfs_emit(buf, "%*pb\n", nr_ids, mask); bitmap_free(mask); return len < PAGE_SIZE ? len : -EINVAL; -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] net-sysfs: switch xps_queue_show() to sysfs_emit() 2026-03-03 18:55 ` [PATCH 2/2] net-sysfs: switch xps_queue_show() to sysfs_emit() Yury Norov @ 2026-03-03 19:16 ` Thomas Weißschuh 0 siblings, 0 replies; 7+ messages in thread From: Thomas Weißschuh @ 2026-03-03 19:16 UTC (permalink / raw) To: Yury Norov Cc: Jakub Kicinski, Paolo Abeni, David S. Miller, Eric Dumazet, Andrew Lunn, Simon Horman, Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob, Subbaraya Sundeep, Stanislav Fomichev, Kuniyuki Iwashima, Christian Brauner, Yajun Deng, netdev, linux-kernel, Yury Norov On 2026-03-03 13:55:06-0500, Yury Norov wrote: > Switch the function to use the proper sysfs_emit("%pb"). > > Suggested-by: Thomas Weißschuh <linux@weissschuh.net> > Signed-off-by: Yury Norov <ynorov@nvidia.com> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> > --- > 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..a260f8b4d5c6 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 = sysfs_emit(buf, "%*pb\n", nr_ids, mask); > bitmap_free(mask); > > return len < PAGE_SIZE ? len : -EINVAL; ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 0/2] net: cleanup bitmaps printing @ 2026-03-19 20:17 Yury Norov 2026-03-19 20:17 ` [PATCH 2/2] net-sysfs: switch xps_queue_show() to sysfs_emit() Yury Norov 0 siblings, 1 reply; 7+ messages in thread From: Yury Norov @ 2026-03-19 20:17 UTC (permalink / raw) To: To : Jakub Kicinski, Paolo Abeni, David S. Miller, Eric Dumazet, Andrew Lunn, Simon Horman, Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob, Subbaraya Sundeep, Stanislav Fomichev, Kuniyuki Iwashima, Christian Brauner, Yajun Deng, netdev, linux-kernel Cc: Yury Norov, Thomas Weißschuh, 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 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/ v2: - fix copy-paste error in print_npa_qsize() (Simon); - fix typo in #1 subject (Jakub). Yury Norov (2): octeontx2-af: siplify rvu_debugfs net-sysfs: switch xps_queue_show() to sysfs_emit() .../marvell/octeontx2/af/rvu_debugfs.c | 28 ++++--------------- net/core/net-sysfs.c | 2 +- 2 files changed, 6 insertions(+), 24 deletions(-) -- 2.43.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] net-sysfs: switch xps_queue_show() to sysfs_emit() 2026-03-19 20:17 [PATCH v2 0/2] net: cleanup bitmaps printing Yury Norov @ 2026-03-19 20:17 ` Yury Norov 0 siblings, 0 replies; 7+ messages in thread From: Yury Norov @ 2026-03-19 20:17 UTC (permalink / raw) To: To : Jakub Kicinski, Paolo Abeni, David S. Miller, Eric Dumazet, Andrew Lunn, Simon Horman, Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob, Subbaraya Sundeep, Stanislav Fomichev, Kuniyuki Iwashima, Christian Brauner, Yajun Deng, netdev, linux-kernel Cc: Yury Norov, Thomas Weißschuh, Yury Norov Switch the function to use the proper sysfs_emit("%pb"). Suggested-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> 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..a260f8b4d5c6 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 = sysfs_emit(buf, "%*pb\n", nr_ids, mask); bitmap_free(mask); return len < PAGE_SIZE ? len : -EINVAL; -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-03-19 20:17 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-03-03 18:55 [PATCH RESEND 0/2] net: cleanup bitmaps printing Yury Norov 2026-03-03 18:55 ` [PATCH 1/2] octeontx2-af: siplify rvu_debugfs Yury Norov 2026-03-05 10:16 ` [1/2] " Simon Horman 2026-03-05 14:55 ` [PATCH 1/2] " Jakub Kicinski 2026-03-03 18:55 ` [PATCH 2/2] net-sysfs: switch xps_queue_show() to sysfs_emit() Yury Norov 2026-03-03 19:16 ` Thomas Weißschuh -- strict thread matches above, loose matches on Subject: below -- 2026-03-19 20:17 [PATCH v2 0/2] net: cleanup bitmaps printing Yury Norov 2026-03-19 20:17 ` [PATCH 2/2] net-sysfs: switch xps_queue_show() to sysfs_emit() Yury Norov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox