Re: [PATCH v2] octeontx2-af: use seq_file for rsrc_alloc debugfs
From: Ratheesh Kannoth <rkannoth@marvell.com>
Date: 2026-09-08 02:27:07
Also in:
lkml
On 2026-09-08 at 07:24:35, Heyang Tan (thy15333007817@163.com) 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,
and write output columns directly to the seq_file buffer.
Fixes: 23205e6d06d4 ("octeontx2-af: Dump current resource provisioning status")
Signed-off-by: Heyang Tan <redacted>
---
Changes in v2:
- Write columns directly to the seq_file buffer as suggested by Ratheesh.Thank you!
+static int rvu_dbg_rsrc_attach_status(struct seq_file *filp, void *unused)
{
- int index, off = 0, flag = 0, len = 0, i = 0;
- struct rvu *rvu = filp->private_data;
- int bytes_not_copied = 0;
+ int index, pf, vf, pcifunc;
+ struct rvu *rvu = filp->private;Reverse xmas tree?
struct rvu_block block; - int pf, vf, pcifunc; - int buf_size = 2048; int lf_str_size; char *lfs; - char *buf; - - /* don't allow partial reads */ - if (*ppos != 0) - return 0; - - buf = kzalloc(buf_size, GFP_KERNEL); - if (!buf) - return -ENOMEM; - /* Get the maximum width of a column */ lf_str_size = get_max_column_width(rvu); + if (lf_str_size < 0) + return lf_str_size; lfs = kzalloc(lf_str_size, GFP_KERNEL);
Do we need this ? can we pass seqfile as well to get_lf_str_list() ? may be rename the function to suit its functionality ?
- if (!lfs) {
- kfree(buf);
+ if (!lfs)
return -ENOMEM;
- }
- off += scnprintf(&buf[off], buf_size - 1 - off, "%-*s", lf_str_size,
- "pcifunc");