Re: [RFC PATCH 1/3] fs/resctrl: Add schema_name to struct resctrl_ctrl
From: Reinette Chatre
Date: Thu Nov 19 2026 - 01:45:46 EST
Hi Ben,
On 9/21/26 6:57 AM, Ben Horgan wrote:
> In order to properly align the schema in the schemata and size file the
> maximum of length of all the schema names needs to be
> known. resctrl_resource_ctrl_max_len() makes this calculation but stops
> short of actually constructing and storing the schema names. As the schema
> name is based on the resource name and the schema name with some special
> cases for legacy controls this leads to a lot of conditional formatting
> when displaying the schema name.
The schema name is based on the "final" resource name. This becomes significant
when CDP is enabled since there may then be two "final" resources,
one per CDP type, but they are backed by the same underlying resource.
The two "final" (CODE/DATA) resources thus share the same controls.
> Construct the schema name and save it to struct resctrl when mounting
> resctrl. This makes displaying the schema name easy whilst control of the
> naming stays within resctrl.
>
> Signed-off-by: Ben Horgan <ben.horgan@xxxxxxx>
> ---
...
> +
> static int final_resources_list_add(struct rdt_resource *r, enum resctrl_conf_type type)
> {
> + struct resctrl_ctrl *ctrl, *em_ctrl;
> struct rdt_resource_final *f;
> const char *suffix = "";
> - int ret, cl;
> + int ret;
>
> f = kzalloc_obj(*f);
> if (!f)
> @@ -3409,24 +3420,32 @@ static int final_resources_list_add(struct rdt_resource *r, enum resctrl_conf_ty
> return -EINVAL;
> }
>
> - cl = strlen(f->name);
> -
> - /*
> - * Maintain tabular format by taking into account the names of all
> - * the resource's controls.
> - */
> - cl += resctrl_resource_ctrl_max_len(f->res);
> -
> - /*
> - * If CDP is supported by this resource, but not enabled,
> - * include the suffix. This ensures the tabular format of the
> - * schemata file does not change between mounts of the filesystem.
> - */
> - if (r->cdp_capable && !resctrl_arch_get_cdp_enabled(r))
> - cl += 4;
> + for_each_resource_ctrl(ctrl, r) {
> + if (resctrl_ctrl_is_default(ctrl)) {
> + ret = snprintf(ctrl->schema_name, sizeof(ctrl->schema_name),
> + "%s", f->name);
> + } else {
> + ret = snprintf(ctrl->schema_name, sizeof(ctrl->schema_name),
> + "%s_%s", f->name, resctrl_ctrl_name_str(ctrl->name));
> + }
> + if (ret >= sizeof(ctrl->schema_name)) {
> + kfree(f);
> + return -EINVAL;
> + }
> + update_max_name_width(r, ctrl->schema_name);
When CDP is enabled final_resources_list_add() is called once per CDP type. Since the CDP types
have the same underlying resource the two calls iterate over the same control objects with
the second iteration overwriting the resctrl_ctrl::schema_name generated during the first iteration.
I am reworking this area to address the conclusions about control naming reached during RFC v2
discussion. These changes that you have not seen yet make it difficult to discuss new ways to
make the schema name easier to display. I am working on addressing this issue as part of v3. We
can revisit then.
Reinette