Re: [PATCH v4 06/39] x86/resctrl: Move data_width to be a schema property
From: James Morse
Date: Fri Sep 13 2024 - 14:08:14 EST
Hi Reinette,
On 14/08/2024 04:59, Reinette Chatre wrote:
> On 8/2/24 10:28 AM, James Morse wrote:
>> The resctrl architecture code gets to specify the width of the schema
>> entries that are used by resctrl. These are determined by the schema
>> format, e.g. percentage or bitmap.
>>
>> Move this property into struct resctrl_schema and get the filesystem
>> parts of resctrl to set it based on the schema format. Remove
>> rdt_init_padding(), its work is be done by schemata_list_add(),
>
> "its work is be done by" -> "its work is done by"
>
>> allowing max_name_width and max_data_width to be moved out of core.c
>> which has no counterpart after the move to fs.
>>
>> The logic for calculating max_name_width was moved in earlier patches,
>
> ("patches" in changelog can be a trigger, maybe "moved in earlier patches"
> -> "moved earlier"?)
>
>> but the definition was not moved.
>> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> index 1ce851447923..ed06384f9161 100644
>> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> @@ -57,6 +57,12 @@ static struct kernfs_node *kn_mongrp;
>> /* Kernel fs node for "mon_data" directory under root */
>> static struct kernfs_node *kn_mondata;
>> +/*
>> + * Used to store the max resource name width and max resource data width
>> + * to display the schemata in a tabular format.
>> + */
>> +int max_name_width, max_data_width;
>> +
>> static struct seq_buf last_cmd_status;
>> static char last_cmd_status_buf[512];
>> @@ -2603,15 +2609,20 @@ static int schemata_list_add(struct rdt_resource *r, enum
>> resctrl_conf_type type
>> switch (r->schema_fmt) {
>> case RESCTRL_SCHEMA_BITMAP:
>> s->fmt_str = "%d=%0*x";
>> + s->data_width = (r->cache.cbm_len + 3) / 4;
>> break;
>> case RESCTRL_SCHEMA_PERCENTAGE:
>> s->fmt_str = "%d=%0*u";
>> + s->data_width = 3;
>> break;
>> case RESCTRL_SCHEMA_MBPS:
>> s->fmt_str = "%d=%0*u";
>> + s->data_width = 4;
>> break;
>> }
>> + max_data_width = max(max_data_width, s->data_width);
>> +
>
> To me this emphasizes that RESCTRL_SCHEMA_PERCENTAGE and
> RESCTRL_SCHEMA_MBPS are not appropriate. Note how the minimum data width
> of RESCTRL_SCHEMA_MBPS is 4, this is unexpected from an actual MBps
> value. The choice of "4" is specific to AMD's input but that information
> is lost in this change.
It's preserving the current behaviour, as AMD is currently the only user.
I strongly suspect the value here is quite wrong, and what we should really do is call
snprintf() to tell us how long the string needs to be.
> We are fortunate that data_width is a minimum, allowing the software controller
> to be enabled with longer data values, but that is subtle and already
> breaks the goal of "making things tabular".
> I wonder how useful the data_width actually is. The "make things tabular"
> motivation seems to only apply to resources that have the exact same scope
> and as noted earlier seems to be broken already.
> I am skeptical that user space will be impacted if this is removed.
Makes sense. I think the only argument could be a parser written for a new kernel would be
surprised if it ran against an older kernel - and we might not care about that scenario.
I can't see how this would happen for the zero-padded values - you'd be going out of your
way to remove leading zeros before working with the field as a number.
It may be a problem for the names which have extra spaces. From what I can tell, an AMD
platform with SMBA must look like something like this:
| SMBA:0=2048
| L3:0=00ff
I'll rip out the data_width - as fixing it, and making it a property resctrl determines
for itself is going to lead to boat over time for no benefit. I'll leave the name_width as
its marginally plausible a regex like "^L3" would misbehave with different kernel versions
on the same machine.
Thanks,
James