Re: [PATCH 10/11] fs/resctrl: Change last_cmd_status custom during input parsing

Ben Horgan
2026-03-17T17:20:10Z

Hi Reinette,

On 3/2/26 18:46, Reinette Chatre wrote:
> A pattern of usage of last_cmd_status was introduced during its enabling in
> commit
>
> c377dcfbee80 ("x86/intel_rdt: Add diagnostics when writing the schemata file")
>
> and since copied throughout resctrl to result in the following custom:
>
> ..._write()
> {
> /* Early parsing of input, exit on failure. */
>
> /* Obtain rdtgroup_mutex */
> rdt_last_cmd_clear(); /* Clear last_cmd_status buffer */
>
> /*
> * Act on user command, failures result in detail
> * error message in last_cmd_status buffer via
> * rdt_last_cmd_puts()/rdt_last_cmd_printf().
> */
>
> /* Release rdtgroup_mutex */
> }
>
> If resctrl exits with failure during early parsing of input there are two
> possible scenarios:
> - The last_cmd_status buffer is empty and a user's read of
> info/last_cmd_status returns "ok".
> - The last_cmd_status buffer contains details from an earlier ...write()
> failure and a user's read of info/last_cmd_status returns this outdated
> error description.
>
> Writing to a resctrl file is considered a "resctrl command" and the
> resctrl documentation states the following about the last_cmd_status file:
> "If the command failed, it will provide more information that can be
> conveyed in the error returns from file operations."
> Neither of the current scenarios is correct behavior.
>
> Move early input parsing to be done with rdtgroup_mutex held after the
> last_cmd_status buffer is cleared. Let info/last_cmd_status be accurate
> when an error is encountered during parsing of user command.

This seems useful and the patch looks good to me.

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

Thanks,

Ben