[PATCH v5 08/10] fs/resctrl: Add last_cmd_status support for writes to max_threshold_occupancy
From: Reinette Chatre
Date: Wed Jul 01 2026 - 00:29:49 EST
info/last_cmd_status is intended to contain more information if a write to
any resctrl file fails. Writes to max_threshold_occupancy did not receive
last_cmd_status support during initial last_cmd_status enabling. Add it now.
Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Reviewed-by: Tony Luck <tony.luck@xxxxxxxxx>
---
Changes since v1:
- Add Ben's RB tag.
Changes since v2:
- Switch to guard(). (Chenyu)
- Drop Ben's RB tag due to significant code change.
Changes since v4:
- Rebased on top of the "x86,fs/resctrl: Fix long-standing issues" series
that added locking helpers to info file handlers.
- Add Tony's Reviewed-by tag.
---
fs/resctrl/rdtgroup.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index a5fe76b0e9eb..0e428d337641 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -1300,14 +1300,20 @@ static ssize_t max_threshold_occ_write(struct kernfs_open_file *of,
unsigned int bytes;
int ret;
- ret = kstrtouint(buf, 0, &bytes);
- if (ret)
- return ret;
-
if (!info_kn_lock(of->kn))
return -ENOENT;
+ rdt_last_cmd_clear();
+
+ ret = kstrtouint(buf, 0, &bytes);
+ if (ret) {
+ rdt_last_cmd_puts("max_threshold_occupancy: Invalid input\n");
+ goto out_unlock;
+ }
+
if (bytes > resctrl_rmid_realloc_limit) {
+ rdt_last_cmd_printf("max_threshold_occupancy: Exceeds limit (before adjustment) of %u bytes\n",
+ resctrl_rmid_realloc_limit);
ret = -EINVAL;
goto out_unlock;
}
--
2.54.0