Re: [PATCH v4 01/31] x86,fs/resctrl: Drop rdt_mon_features variable
From: Reinette Chatre
Date: Thu May 08 2025 - 19:44:42 EST
Hi Tony,
On 5/8/25 11:32 AM, Luck, Tony wrote:
> On Wed, May 07, 2025 at 08:28:56PM -0700, Reinette Chatre wrote:
>> On 4/28/25 5:33 PM, Tony Luck wrote:
...
>>> Change architecture code to inform file system code which events are
>>> available on a system with resctrl_enable_mon_event().
>>
>> (nit: no need to mention that a patch changes code, it should be implied.)
>>
>> This could be, "An architecture uses resctrl_enable_mon_event() to inform
>> resctrl fs which events are enabled on the system."
>
> Will update with this.
>
>> (I think we need to be cautious about the "available" vs "enabled"
>> distinction.)
>
> Maybe a comment above mon_event_all[]?
Good idea.
>
> /*
> * All available events. Architecture code marks the ones that
I think "available" may be interpreted differently by people.
How about "All known events."?
> * are supported by a system using resctrl_enable_mon_event()
> * to set .enabled.
> */
> struct mon_evt mon_event_all[QOS_NUM_EVENTS] = {
>
>>>
>>> Replace the event and architecture specific:
>>> resctrl_arch_is_llc_occupancy_enabled()
>>> resctrl_arch_is_mbm_total_enabled()
>>> resctrl_arch_is_mbm_local_enabled()
>>> functions with calls to resctrl_is_mon_event_enabled() with the
>>> appropriate QOS_L3_* enum resctrl_event_id.
>>
>> No mention or motivation for the new array. I think the new array is an
>> improvement and now it begs the question whether rdt_resource::evt_list is
>> still needed? It seems to me that any usage of rdt_resource::evt_list can
>> use the new mon_event_all[] instead?
>
> Good suggestion. rdt_resource::evt_list can indeed be dropped. A
> standalone patch to do so reduces lines of code:
>
> include/linux/resctrl.h | 2 --
> fs/resctrl/internal.h | 2 --
> fs/resctrl/monitor.c | 18 +-----------------
> fs/resctrl/rdtgroup.c | 11 ++++++-----
> 4 files changed, 7 insertions(+), 26 deletions(-)
>
> But I'll merge into one of the early patches to avoid adding new code to create
> the evt_list and then delete it again.
Thanks for considering.
>
>> With struct mon_evt being independent like before this
>> patch it almost seems as though it prepared for multiple resources to
>> support the same event (do you know history here?). This appears to already
>> be thwarted by rdt_mon_features though ... although theoretically it could
>> have been "rdt_l3_mon_features".
>> Even so, with patch #4 adding the resource ID all event information is
>> centralized. Only potential issue may be if multiple resources use the
>> same event ... but since the existing event IDs already have resource
>> name embedded this does not seem to be of concern?
>
> The existing evt_list approach would corrupt the lists if the same event
> were added to multiple resources. Without the list this becomes
> possible, but seems neither desirable, nor useful.
ack. With an event array indexed by event ID it would also take some additional
changes to support.
>
> I will add a warning to resctrl_enable_mon_event() if architecture
> code tries to enable an already enabled event.
Thank you very much.
>>
>>>
>>> Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
>>> ---
>>
>> ...
>>
>>> @@ -866,14 +879,13 @@ static struct mon_evt mbm_local_event = {
>>> */
>>> static void l3_mon_evt_init(struct rdt_resource *r)
>>> {
>>> + enum resctrl_event_id evt;
>>> +
>>> INIT_LIST_HEAD(&r->evt_list);
>>>
>>> - if (resctrl_arch_is_llc_occupancy_enabled())
>>> - list_add_tail(&llc_occupancy_event.list, &r->evt_list);
>>> - if (resctrl_arch_is_mbm_total_enabled())
>>> - list_add_tail(&mbm_total_event.list, &r->evt_list);
>>> - if (resctrl_arch_is_mbm_local_enabled())
>>> - list_add_tail(&mbm_local_event.list, &r->evt_list);
>>> + for (evt = 0; evt < QOS_NUM_EVENTS; evt++)
>>> + if (mon_event_all[evt].enabled)
>>> + list_add_tail(&mon_event_all[evt].list, &r->evt_list);
>>> }
>>
>> This hunk can create confusion with it adding "all enabled events" to
>> a single resource. I understand that at this point only L3 supports monitoring
>> and this works ok, but in the context of this work it creates a caveat early
>> in series that needs to be fixed later (patch #4). This wrangling becomes
>> unnecessary if removing rdt_resource::evt_list.
>
> I'll see if I can get a clean sequence between these patches to avoid
> this confusion. Maybe evt_list removal needs to happen here.
Thank you.
Reinette