Re: [PATCH 00/11] x86,fs/resctrl: Improve resctrl quality and consistency

Reinette Chatre
2026-03-16T18:18:21Z

Hi Ben,

On 3/16/26 10:44 AM, Ben Horgan wrote:
> On 3/2/26 18:46, Reinette Chatre wrote:
...
> One related issue I've just noticed is that when ABMC and mbm_assign_on_mkdir are
> enabled the creation of MON/CTRL_MON directories may succeed but an error message
> is written to last_cmd_status. E.g.
>
> /sys/fs/resctrl# mkdir mon_groups/new5
> /sys/fs/resctrl# cat info/last_cmd_status
> Failed to allocate counter for mbm_total_bytes in domain 2
>
> The failure is ignored, as expected, in rdt_assign_cntrs() but the last_cmd_status
> is never cleared. I think this could be fixed by:
>
> diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
> index 62edb464410a..396f17ed72c6 100644
> --- a/fs/resctrl/monitor.c
> +++ b/fs/resctrl/monitor.c
> @@ -1260,6 +1260,8 @@ void rdtgroup_assign_cntrs(struct rdtgroup *rdtgrp)
> if (resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID))
> rdtgroup_assign_cntr_event(NULL, rdtgrp,
> &mon_event_all[QOS_L3_MBM_LOCAL_EVENT_ID]);
> +
> + rdt_last_cmd_clear();
> }
>
> Is this right thing to do? Let me know if you want a proper patch.

Letting group be created without any counters assigned while writing the error
to last_cmd_status is the intended behavior. If the last_cmd_status buffer is cleared
at this point then user space will never have the opportunity to see the message that
contains the details.

It did not seem appropriate to let resource group creation fail when no counters
are available. I see that the documentation is not clear on this. What do you think
of an update to documentation instead? Would something like below help clarify behavior?

diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesystems/resctrl.rst
index ba609f8d4de5..20dc58d281cf 100644
--- a/Documentation/filesystems/resctrl.rst
+++ b/Documentation/filesystems/resctrl.rst
@@ -478,6 +478,12 @@ with the following files:
# cat /sys/fs/resctrl/info/L3_MON/mbm_assign_on_mkdir
0

+ Automatic counter assignment is done with best effort. If auto assignment
+ is enabled but there are not enough available counters then monitor group
+ creation could succeed while one or more events belonging to the group may
+ not have a counter assigned. Consult last_cmd_status for details during
+ such scenario.
+
"max_threshold_occupancy":
Read/write file provides the largest value (in
bytes) at which a previously used LLC_occupancy

Reinette