[PATCH v2 14/14] fs/resctrl: Inform user space when status buffer overflowed

Reinette Chatre posted 14 patches 2 weeks ago
[PATCH v2 14/14] fs/resctrl: Inform user space when status buffer overflowed
Posted by Reinette Chatre 2 weeks ago
resctrl fs commands are becoming more powerful with, for example, a user
able to use syntax like '*' to make broad configuration changes. Such
commands that span multiple domains may result in more than one message
printed to the last_cmd_status buffer with more planned.

Display "[truncated]" to user space when displaying the last_cmd_status
buffer to communicate if it overflowed. Upon encountering this user space
is expected to combine details about the failure found in info/last_cmd_status
with related resctrl files to learn the accurate system state after the
command failure.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
 fs/resctrl/rdtgroup.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 0f753a820702..85d3ec36cd95 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -973,10 +973,13 @@ static int rdt_last_cmd_status_show(struct kernfs_open_file *of,
 
 	mutex_lock(&rdtgroup_mutex);
 	len = seq_buf_used(&last_cmd_status);
-	if (len)
+	if (len) {
 		seq_printf(seq, "%.*s", len, last_cmd_status_buf);
-	else
+		if (seq_buf_has_overflowed(&last_cmd_status))
+			seq_puts(seq, "[truncated]\n");
+	} else {
 		seq_puts(seq, "ok\n");
+	}
 	mutex_unlock(&rdtgroup_mutex);
 	return 0;
 }
-- 
2.50.1
Re: [PATCH v2 14/14] fs/resctrl: Inform user space when status buffer overflowed
Posted by Ben Horgan 1 week, 4 days ago
Hi Reinette,

On 3/20/26 22:03, Reinette Chatre wrote:
> resctrl fs commands are becoming more powerful with, for example, a user
> able to use syntax like '*' to make broad configuration changes. Such
> commands that span multiple domains may result in more than one message
> printed to the last_cmd_status buffer with more planned.
> 
> Display "[truncated]" to user space when displaying the last_cmd_status
> buffer to communicate if it overflowed. Upon encountering this user space
> is expected to combine details about the failure found in info/last_cmd_status
> with related resctrl files to learn the accurate system state after the
> command failure.

LGTM:

Reviewed-by: Ben Horgan <ben.horgan@arm.com>

Thanks,

Ben