Re: [PATCH v8 16/21] x86/resctrl: Always initialise rid field in rdt_resources_all[]
From: James Morse
Date: Thu Apr 24 2025 - 13:08:19 EST
Hi Tony,
On 15/04/2025 20:08, Luck, Tony wrote:
> On Fri, Apr 11, 2025 at 04:42:24PM +0000, James Morse wrote:
>> x86 has an array, rdt_resources_all[], of all possible resources.
>> The for-each-resource walkers depend on the rid field of all
>> resources being initialised.
>>
>> If the array ever grows due to another architecture adding a resource
>> type that is not defined on x86, the for-each-resources walkers will
>> loop forever.
> This feels a bit weird. Having rdt_resources_all[] be a "swiss cheese"
> array full of holes where other architectures defined events that aren't
> supported by x86.
Today, there are none of those for x86. The MPAM driver has to do this, but so far the
array is small. I agree if the array becomes large, and no architecture implements
everything then some other structure would be better.
> But it does work, so it can go in like this. But someday I may revisit
> some experimental patches I did a while back that:
> 1) Split the rdt_resource structure into separate "ctrl" and "mon"
> pieces.
> 2) Replaced this array with a pair of lists, one each for enabled
> ctrl and mon resources.
> 3) Changed the resource walkers to use list_for_each*() macros.
Sounds good - this matches what the schema list has become.
The only oddity is the newly proposed "resctrl_online_domains_exist()" that would
sanity-check a resctrl_exit() call - but I don't see a problem walking one list after the
other there.
Thanks,
James