Re: [PATCH v3] octeontx2-af: use seq_file for rsrc_alloc debugfs
From: Ratheesh Kannoth
Date: Tue Sep 08 2026 - 23:05:28 EST
On 2026-09-09 at 07:24:37, Heyang Tan (thy15333007817@xxxxxxx) wrote:
> The rsrc_alloc debugfs reader writes rows directly to userspace without
> respecting the caller's read count. It also uses the current row length as
> the userspace stride, which can corrupt output when rows have different
> widths.
>
> Use seq_file to handle userspace buffer sizes, offsets, and partial reads.
>
> The LF list formatter is used both to determine the widest column and skip
> PF/VF rows with no resources, and to emit the final table. Let it measure
> the formatted length when no seq_file is supplied, and write directly to
> the seq_file during rendering. This preserves the pre-scan behavior while
> removing the temporary string buffers.
>
> Fixes: 23205e6d06d4 ("octeontx2-af: Dump current resource provisioning status")
> Assisted-by: LLM Codex
> Signed-off-by: Heyang Tan <thy15333007817@xxxxxxx>
>
> Changes in v3:
> - Format LF lists directly in the seq_file buffer and remove temporary buffers.
> - Measure, rather than emit, LF lists during width calculation and row scans.
> - Explain the two formatter modes in a code comment.
> - Preserve column alignment with seq_setwidth() and seq_pad().
> - Reorder local declarations in reverse Christmas tree order.
>
> Link: https://lore.kernel.org/netdev/20260906141129.1730-1-thy15333007817@xxxxxxx/
> ---
> .../marvell/octeontx2/af/rvu_debugfs.c | 114 +++++++++++-------
> 1 file changed, 69 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> index fcbf4ba0e10a..1f177851e76d 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> @@ -646,10 +646,29 @@ static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,
>
> RVU_DEBUG_FOPS(lmtst_map_table, lmtst_map_table_display, NULL);
>
> -static void get_lf_str_list(const struct rvu_block *block, int pcifunc,
> - char *lfs)
> +static int get_num_digits(int number)
> {
> - int lf = 0, seq = 0, len = 0, prev_lf = block->lf.max;
> + int width = 1;
> +
> + while (number >= 10) {
> + number /= 10;
> + width++;
> + }
> +
> + return width;
> +}
Sorry for the confusion here! My previous comment was strictly a "nice-to-have"
suggestion and wasn't intended to trigger a larger scope expansion. Given that
this is a targeted bug fix, keeping the diff minimal and low-risk is the
priority. Your v2 patch addressed the core issue cleanly without unnecessary
churn. Could you please revert/repost the v2 version as v4 ? We can always handle any
extra cleanup in a separate follow-up to net-next if needed. Thanks for your help.