Re: [PATCH v6 02/42] x86/resctrl: Add a helper to avoid reaching into the arch code resource list
From: James Morse
Date: Fri Feb 28 2025 - 14:54:14 EST
Hi Babu,
(please don't top post!)
On 27/02/2025 20:24, Moger, Babu wrote:
> On 2/7/25 12:17, James Morse wrote:
>> Resctrl occasionally wants to know something about a specific resource,
>> in these cases it reaches into the arch code's rdt_resources_all[]
>> array.
>>
>> Once the filesystem parts of resctrl are moved to /fs/, this means it
>> will need visibility of the architecture specific struct
>> rdt_hw_resource definition, and the array of all resources. All
>> architectures would also need a r_resctrl member in this struct.
>>
>> Instead, abstract this via a helper to allow architectures to do
>> different things here. Move the level enum to the resctrl header and
>> add a helper to retrieve the struct rdt_resource by 'rid'.
>>
>> resctrl_arch_get_resource() should not return NULL for any value in
>> the enum, it may instead return a dummy resource that is
>> !alloc_enabled && !mon_enabled.
> You probably missed few cases here.
>
> static int logical_rmid_to_physical_rmid(int cpu, int lrmid)
> {
> struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
> --
>
> }
>
> Any reason not use the new call resctrl_arch_get_resource() here?
Simply there is no need to! That code doesn't get moved to /fs/, so it doesn't need to use
a helper. Taken to its extreme - after the code is moved to /fs/, there are no callers of
resctrl_arch_get_resource() in the arch code, because whatever they do today is sufficent.
Thanks,
James