Re: [PATCH v5 05/40] x86/resctrl: Use schema type to determine the schema format string
From: Reinette Chatre
Date: Mon Oct 21 2024 - 13:39:38 EST
Hi James,
On 10/4/24 11:03 AM, James Morse wrote:
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index 11153271cbdc..896350e9fb32 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -2600,6 +2600,15 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type
> if (cl > max_name_width)
> max_name_width = cl;
>
> + switch (r->schema_fmt) {
> + case RESCTRL_SCHEMA_BITMAP:
> + s->fmt_str = "%d=%0*x";
> + break;
> + case RESCTRL_SCHEMA_RANGE:
> + s->fmt_str = "%d=%0*u";
> + break;
> + }
> +
The parsing of user input happens after the creation of the schema list. If the goal
is to protect against incorrect arch settings then I think schemata_list_add() initialization of
s->fmt_str needs similar WARN_ON_ONCE() treatment as planned [1] for parse_ctrlval within
parse_line().
Reinette
[1] https://lore.kernel.org/all/d48e65cc-3c7b-4a93-80a2-fa0d676e88c4@xxxxxxx/